Upgraded to latest aerogo/log

This commit is contained in:
Eduard Urbach 2019-05-07 23:01:51 +09:00
parent 483622df09
commit 868ba2ba99
8 changed files with 55 additions and 42 deletions

View File

@ -1,7 +1,9 @@
package auth
import "github.com/aerogo/aero"
import "github.com/animenotifier/notify.moe/utils"
import (
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/utils"
)
const newUserStartRoute = "/welcome"
@ -22,7 +24,7 @@ func Install(app *aero.Application) {
user := utils.GetUser(ctx)
if user != nil {
authLog.Info("User logged out", user.ID, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("%s logged out | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
}
ctx.Session().Set("userId", nil)

View File

@ -108,7 +108,7 @@ func InstallFacebookAuth(app *aero.Application) {
user.Save()
// Log
authLog.Info("Added Facebook ID to existing account", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("Added Facebook ID to existing account | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
return ctx.Redirect("/")
}
@ -119,7 +119,7 @@ func InstallFacebookAuth(app *aero.Application) {
user, getErr = arn.GetUserByFacebookID(fbUser.ID)
if getErr == nil && user != nil {
authLog.Info("User logged in via Facebook ID", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("User logged in via Facebook ID | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
// Add FacebookToUser reference
user.ConnectFacebook(fbUser.ID)
@ -135,7 +135,7 @@ func InstallFacebookAuth(app *aero.Application) {
user, getErr = arn.GetUserByEmail(fbUser.Email)
if getErr == nil && user != nil {
authLog.Info("User logged in via Email", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("User logged in via Email | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
user.LastLogin = arn.DateTimeUTC()
user.Save()
@ -169,7 +169,7 @@ func InstallFacebookAuth(app *aero.Application) {
session.Set("userId", user.ID)
// Log
authLog.Info("Registered new user via Facebook", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("Registered new user via Facebook | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
// Redirect to starting page for new users
return ctx.Redirect(newUserStartRoute)

View File

@ -119,7 +119,7 @@ func InstallGoogleAuth(app *aero.Application) {
user.Save()
// Log
authLog.Info("Added Google ID to existing account", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("Added Google ID to existing account | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
return ctx.Redirect("/")
}
@ -130,7 +130,7 @@ func InstallGoogleAuth(app *aero.Application) {
user, getErr = arn.GetUserByGoogleID(googleUser.Sub)
if getErr == nil && user != nil {
authLog.Info("User logged in via Google ID", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("User logged in via Google ID | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
user.LastLogin = arn.DateTimeUTC()
user.Save()
@ -143,7 +143,7 @@ func InstallGoogleAuth(app *aero.Application) {
user, getErr = arn.GetUserByEmail(googleUser.Email)
if getErr == nil && user != nil {
authLog.Info("User logged in via Email", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("User logged in via Email | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
// Add GoogleToUser reference
user.ConnectGoogle(googleUser.Sub)
@ -180,7 +180,7 @@ func InstallGoogleAuth(app *aero.Application) {
session.Set("userId", user.ID)
// Log
authLog.Info("Registered new user via Google", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("Registered new user via Google | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
// Redirect to starting page for new users
return ctx.Redirect(newUserStartRoute)

View File

@ -9,6 +9,6 @@ import (
var authLog = log.New()
func init() {
authLog.AddOutput(os.Stdout)
authLog.AddOutput(log.File("logs/auth.log"))
authLog.AddWriter(os.Stdout)
authLog.AddWriter(log.File("logs/auth.log"))
}

View File

@ -120,7 +120,7 @@ func InstallTwitterAuth(app *aero.Application) {
user.Save()
// Log
authLog.Info("Added Twitter ID to existing account", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("Added Twitter ID to existing account | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
return ctx.Redirect("/")
}
@ -131,7 +131,7 @@ func InstallTwitterAuth(app *aero.Application) {
user, getErr = arn.GetUserByTwitterID(twUser.ID)
if getErr == nil && user != nil {
authLog.Info("User logged in via Twitter ID", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("User logged in via Twitter ID | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
user.LastLogin = arn.DateTimeUTC()
user.Save()
@ -144,7 +144,7 @@ func InstallTwitterAuth(app *aero.Application) {
user, getErr = arn.GetUserByEmail(twUser.Email)
if getErr == nil && user != nil {
authLog.Info("User logged in via Email", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("User logged in via Email | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
// Add TwitterToUser reference
user.ConnectTwitter(twUser.ID)
@ -186,7 +186,7 @@ func InstallTwitterAuth(app *aero.Application) {
session.Set("userId", user.ID)
// Log
authLog.Info("Registered new user via Twitter", user.ID, user.Nick, ctx.RealIP(), user.Email, user.RealName())
authLog.Info("Registered new user via Twitter | %s | %s | %s | %s | %s", user.Nick, user.ID, ctx.RealIP(), user.Email, user.RealName())
// Redirect to starting page for new users
return ctx.Redirect(newUserStartRoute)

6
go.mod
View File

@ -8,11 +8,13 @@ require (
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
github.com/aerogo/aero v1.1.7
github.com/aerogo/api v0.1.6
github.com/aerogo/cluster v0.1.6 // indirect
github.com/aerogo/crawler v0.2.1
github.com/aerogo/http v1.0.3
github.com/aerogo/layout v0.1.5
github.com/aerogo/log v0.1.3
github.com/aerogo/log v0.2.4
github.com/aerogo/markdown v0.1.5
github.com/aerogo/mirror v0.1.4 // indirect
github.com/aerogo/nano v0.1.7
github.com/aerogo/pack v0.4.0
github.com/aerogo/run v0.1.4
@ -20,7 +22,7 @@ require (
github.com/aerogo/sitemap v0.1.1
github.com/akyoto/color v1.8.3
github.com/animenotifier/anilist v0.2.2
github.com/animenotifier/arn v1.1.15
github.com/animenotifier/arn v1.1.16
github.com/animenotifier/kitsu v0.2.2
github.com/animenotifier/mal v0.2.2
github.com/animenotifier/shoboi v0.2.2

28
go.sum
View File

@ -14,20 +14,18 @@ github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 h1:UUppSQnhf4Yc6
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/aerogo/aero v1.1.1 h1:EgFwiU87K3Zt+rhkrzx4+U412pMi5onRsDKhMOfJCpU=
github.com/aerogo/aero v1.1.1/go.mod h1:GD7hyz4bLaDumYYNVJogq7ZjWZqmHpRPbkSl11MAhHI=
github.com/aerogo/aero v1.1.2 h1:O01aVpwkMhtExRdK7ebibZlF6J2todKzrTNaB2SILlc=
github.com/aerogo/aero v1.1.2/go.mod h1:2eeRN7zcyVq+wYNu3lnJBS7To5xDxKcJ89ay4GBchig=
github.com/aerogo/aero v1.1.6 h1:WGRxjYJorWUlSsrtLq9xXiMlbeO3xSS+GKMyRhS2eRk=
github.com/aerogo/aero v1.1.6/go.mod h1:WAM3BRkVDU8Eid6wdOyVdCG5DZXLMmbUa+rVedKHx3E=
github.com/aerogo/aero v1.1.7 h1:i53mdWf/Zx/inwATpRmCtCJ5jgYdiJgd2s4hxTgvKxo=
github.com/aerogo/aero v1.1.7/go.mod h1:Ak2cdaWuZmfUDlbTdh07bXSXL6CbcmzkeHE4+ODk/ww=
github.com/aerogo/api v0.1.5 h1:P4HwoPvbSzHaTucSax0o8CDj4AMHNeJ0I55Ir3Y/rMI=
github.com/aerogo/api v0.1.5/go.mod h1:SajJMM1q5ARitmCfPkKEFMJtozHbJo5AA+SLBRgozgU=
github.com/aerogo/api v0.1.6 h1:4aPEYDfvgR9LwuAaY41EM9yBfbjwnpkLMEneQqu5bKo=
github.com/aerogo/api v0.1.6/go.mod h1:I/vbQmYBTUlbonDRdnP0bM4ybt0ZC9fM95LW0BrSrjQ=
github.com/aerogo/cluster v0.1.4 h1:mOTGqSicLyh9s7viVaniov6lCMLs6bTz/nkeJaEul+o=
github.com/aerogo/cluster v0.1.4/go.mod h1:lsMuIQ2gNlA0xUD9PJTGohL4nsbqH5WYS8l5d1XPRN4=
github.com/aerogo/cluster v0.1.5 h1:mOYQmaYRsvIi1inaGLICmeJgCYycBxiHnjcTFLtC6kc=
github.com/aerogo/cluster v0.1.5/go.mod h1:uFZAv2XWV+/clNy0iciCIP2Ygndv8rC8QCX/RCO2R2g=
github.com/aerogo/cluster v0.1.6 h1:9HYjJwo19uuh9thIc80T3caap9t9b4BXZ1iN8aztjlU=
github.com/aerogo/cluster v0.1.6/go.mod h1:XzYmY5MqNxASmYQWFMh5iCl4tcm1ekReaCQQXVCpJtY=
github.com/aerogo/codetree v1.2.1 h1:Mmj8YBMDx2/OhdA+fOTo6Vc7MwPHkOtKmPqVM48xHHg=
github.com/aerogo/codetree v1.2.1/go.mod h1:MhElfskRtfAKGy5ukRIFcLTtHcSCwLRBjDAlsbuFts0=
github.com/aerogo/crawler v0.2.1 h1:UjRjHU1kC5oWH44dcF/31SEWdlYuIH+LNiPbd+kYvdg=
@ -54,12 +52,14 @@ github.com/aerogo/linter-performance v1.0.0 h1:p+v7jfDHFXGzJ367iTdmKk2dKiqtz/TkH
github.com/aerogo/linter-performance v1.0.0/go.mod h1:rsWhUG/KiUz+WRGSRkyN5kxbY1QEOshDdvW3zYAjF+Q=
github.com/aerogo/linter-performance v1.0.1 h1:/1Hak+7sxpO2AkjdMVcpkyurmA4YD77EDi7FRnLqnwM=
github.com/aerogo/linter-performance v1.0.1/go.mod h1:3ZXxPgQ0cEo0x6DCGZwXHrwKNYK86XvB5QRJR9s7Z6I=
github.com/aerogo/log v0.1.3 h1:qnNK3VmNWv6tHHcAY1Sr1dk6+v0jEMefpxbyF5QiI9Q=
github.com/aerogo/log v0.1.3/go.mod h1:oCMbDHUynW5L04OZusEjCufSw4WVF8NAPy1vbspIDeM=
github.com/aerogo/log v0.2.4 h1:xHqrH+tBJQzhZwNPv34K7LNWEo059dxf35yDHS2t0Dw=
github.com/aerogo/log v0.2.4/go.mod h1:ikGYpBw7x5FtDb5Gtqcpt4yW4Lb6rfhncLD0Myuq0dc=
github.com/aerogo/markdown v0.1.5 h1:rzgRDgI7pL/c9Z+wu2Q9rVqr+a8gyB8tmGGl3Ce8Xxk=
github.com/aerogo/markdown v0.1.5/go.mod h1:e/ZnjP3vdg1yB5XKK89r/lAAqNRW6aqaD1dSZaTW2F4=
github.com/aerogo/mirror v0.1.3 h1:813FatCdChOvgWen2EcZNnRfxAeo9zmu/TgDNOnsDx0=
github.com/aerogo/mirror v0.1.3/go.mod h1:Un87Jq8RIRrb2bU1CxVToJjVZgSMLUQXxVLCXln4rUU=
github.com/aerogo/mirror v0.1.4 h1:zCv8UV/C6sOdOyIuVMejcATocLVbL3zJeUwMtib4ex8=
github.com/aerogo/mirror v0.1.4/go.mod h1:Un87Jq8RIRrb2bU1CxVToJjVZgSMLUQXxVLCXln4rUU=
github.com/aerogo/nano v0.1.6 h1:FtWokAa8SZcm5kHlW10OkaUnqlFE4eQGvEfkiSBVsek=
github.com/aerogo/nano v0.1.6/go.mod h1:NxWlxJWtm2s4gB4CcJGy5Lsofz1ZgvEGtv5dEQVNa94=
github.com/aerogo/nano v0.1.7 h1:usInw70W0/OPyUVML2qXi2kLr3K1dMzIyyG3iz5Ccak=
@ -70,6 +70,8 @@ github.com/aerogo/packet v0.1.3 h1:8SrI9KLYQiGAcDElvWeXAKqnydSIBDw0H5+y4A1fZuM=
github.com/aerogo/packet v0.1.3/go.mod h1:/t25yF9WG8B5/QB7wTiHLqwCEQ+nAze7uNm/JJNDQbQ=
github.com/aerogo/packet v0.1.4 h1:435YxvxMiH1KaBPELU+jCLqj0T9noLBSY4zk53t1gpQ=
github.com/aerogo/packet v0.1.4/go.mod h1:/t25yF9WG8B5/QB7wTiHLqwCEQ+nAze7uNm/JJNDQbQ=
github.com/aerogo/packet v0.1.5 h1:+J9VyVGlXnmaynukktwc7d+/nGxX7hBSNSj/7X8tg90=
github.com/aerogo/packet v0.1.5/go.mod h1:/t25yF9WG8B5/QB7wTiHLqwCEQ+nAze7uNm/JJNDQbQ=
github.com/aerogo/pixy v1.2.1 h1:iJ51henDzj+bC6UXjJ4Ki4Aa2MG+5K4L+vCjvUc2bX0=
github.com/aerogo/pixy v1.2.1/go.mod h1:rHP/Y/gbzjVdGZHFfyt4XLaEFP+5tzvnh/k+7/tYPZc=
github.com/aerogo/run v0.1.4 h1:CMO9eZsMDxgvlkx/YX4jXypymXFIKP3/KAaNNo8zoTY=
@ -82,8 +84,6 @@ github.com/aerogo/session v0.1.2 h1:f0X3YJQJcFhtmw47U60jdSsH18/T51SkhkhAuXwnYI8=
github.com/aerogo/session v0.1.2/go.mod h1:A4S5dvAhpm+DRdQbno5Rn4Jvj0UVGJmOUKQXataNIDg=
github.com/aerogo/session-store-memory v0.1.1 h1:ak8uPsbCtkX9yRWS+jWk+iJ8CI3MU/dNyZ0maIGRCJY=
github.com/aerogo/session-store-memory v0.1.1/go.mod h1:TRJb7R48J2wdeUsbZUg5KM+s8UB8F3kt6o4UhGcrFb8=
github.com/aerogo/session-store-memory v0.1.2 h1:cMW37hSw40f3C33QewJSr7uK9/oNSVFOt18F7Z5BGl8=
github.com/aerogo/session-store-memory v0.1.2/go.mod h1:LiE9UU+yI4pDl+nNVKDdmoKcmc+kaV0pW+b+R00YTrs=
github.com/aerogo/session-store-memory v0.1.3 h1:6tPSh4HrJald0akOQIdUc8S1MxmBaOs1eXgC9Yiz2co=
github.com/aerogo/session-store-memory v0.1.3/go.mod h1:GYiLJNk8h3pcBB/UwfCJrtTZl1CLxBg8xnzt45wPmIM=
github.com/aerogo/session-store-nano v0.1.3 h1:k1KjV7yBCHEmib7jWoAgCXGZR4OKH73dHPtpuBXdynA=
@ -110,10 +110,10 @@ github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRy
github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/animenotifier/anilist v0.2.2 h1:zLL9KabDJx2a+yNT+b13ORWvKlLTsFL67hBKLXyImSI=
github.com/animenotifier/anilist v0.2.2/go.mod h1:orL7qr/k64K2YEUYESjr1rhp6+0BXdJmiANxG3OV30U=
github.com/animenotifier/arn v1.1.15 h1:yyhIWGDhFs7dVDK6/itp2bej+oWaMBpF//kuoqMP9m4=
github.com/animenotifier/arn v1.1.15/go.mod h1:3PKzl29mOYRP0vG9lcCP1DTFI1TT6uQeTT+hhAe11mI=
github.com/animenotifier/ffxiv v0.1.0 h1:N9gX5iUtD+g/KW4OjKIclS0y2WrL/+Ko9rGEFDaLf1w=
github.com/animenotifier/ffxiv v0.1.0/go.mod h1:oBHhRzQAUv+dBe4qFJAFnTg7qv5Gl6QFHQphyJla74Q=
github.com/animenotifier/arn v1.1.16 h1:uVkDNnqJyZT9OAep3ddPvqQY9B4RsX6mOH2auekdQDc=
github.com/animenotifier/arn v1.1.16/go.mod h1:c4v232l3UZOi9Yw4DumISzlFME3kApZNDBnqb4a0vtg=
github.com/animenotifier/ffxiv v0.2.0 h1:I6LgRtV1MOH/CYxyGlU3hQzLOuof2hMhLvQivRDY1JE=
github.com/animenotifier/ffxiv v0.2.0/go.mod h1:95gF9YZXwmFiXqXTeIQ6VP5qfsErIguQb1q6w2f6Etk=
github.com/animenotifier/japanese v0.2.2 h1:3+jJvwlA6K7ijFsVPA/coQlwQE3ca6PkNpNMBhYi9tc=
github.com/animenotifier/japanese v0.2.2/go.mod h1:HLrrnBE9ztkw9iMcVrm7DKaXydAq21UpZIp1MpKajQI=
github.com/animenotifier/kitsu v0.2.2 h1:+OzzNO187GyUocn6vJMabxSNkTAz9DIqPQLMLDbqSDY=
@ -252,6 +252,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284 h1:rlLehGeYg6jfoyz/eDqDU1iRXLKfR42nnNh57ytKEWo=
golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
@ -297,6 +299,8 @@ golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872 h1:cGjJzUd8RgBw428LXP65YXni0
golang.org/x/sys v0.0.0-20190429190828-d89cdac9e872/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82 h1:vsphBvatvfbhlb4PO1BYSr9dzugGxJ/SQHoNufZJq1w=
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507053917-2953c62de483 h1:0pONs62zZ8ED8kUnSCsv4RWjmwM6ideAalXGTybpo2s=
golang.org/x/sys v0.0.0-20190507053917-2953c62de483/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=

View File

@ -18,10 +18,15 @@ var ipLog = log.New()
// Initialize log files
func init() {
requestLog.AddOutput(log.File("logs/request.log"))
errorLog.AddOutput(log.File("logs/error.log"))
errorLog.AddOutput(os.Stderr)
ipLog.AddOutput(log.File("logs/ip.log"))
// The request log contains every single request to the server
requestLog.AddWriter(log.File("logs/request.log"))
// The IP log contains the IPs accessing the server
ipLog.AddWriter(log.File("logs/ip.log"))
// The error log contains all failed requests
errorLog.AddWriter(log.File("logs/error.log"))
errorLog.AddWriter(os.Stderr)
}
// Log middleware logs every request into logs/request.log and errors into logs/error.log.
@ -51,19 +56,19 @@ func logRequest(ctx *aero.Context, responseTime time.Duration) {
hostNames, cached := GetHostsForIP(ip)
if !cached && len(hostNames) > 0 {
ipLog.Info(ip, strings.Join(hostNames, ", "))
ipLog.Info("%s = %s", ip, strings.Join(hostNames, ", "))
}
// Log every request
id := "[id]"
nick := "[guest]"
id := "id"
nick := "guest"
if user != nil {
id = user.ID
nick = user.Nick
}
requestLog.Info(nick, id, ip, responseTimeString, ctx.StatusCode, ctx.URI())
requestLog.Info("%s | %s | %s | %s | %d | %s", nick, id, ip, responseTimeString, ctx.StatusCode, ctx.URI())
// Log all requests that failed
switch ctx.StatusCode {
@ -71,12 +76,12 @@ func logRequest(ctx *aero.Context, responseTime time.Duration) {
// Ok.
default:
errorLog.Error(nick, id, ip, responseTimeString, ctx.StatusCode, ctx.URI(), ctx.ErrorMessage)
errorLog.Error("%s | %s | %s | %s | %d | %s (%s)", nick, id, ip, responseTimeString, ctx.StatusCode, ctx.URI(), ctx.ErrorMessage)
}
// Notify us about long requests.
// However ignore requests under /auth/ because those depend on 3rd party servers.
if responseTime >= 300*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") && !strings.HasPrefix(ctx.URI(), "/sitemap/") && !strings.HasPrefix(ctx.URI(), "/api/sse/") {
errorLog.Error("Long response time", nick, id, ip, responseTimeString, ctx.StatusCode, ctx.URI())
if responseTime >= 500*time.Millisecond && !strings.HasPrefix(ctx.URI(), "/auth/") && !strings.HasPrefix(ctx.URI(), "/sitemap/") && !strings.HasPrefix(ctx.URI(), "/api/sse/") {
errorLog.Error("%s | %s | %s | %s | %d | %s (long response time)", nick, id, ip, responseTimeString, ctx.StatusCode, ctx.URI())
}
}