@@ -80,7 +80,7 @@ func initContextWithAnonymousUser(ctx *Context) bool {
80
80
func initContextWithUserSessionCookie (ctx * Context ) bool {
81
81
// initialize session
82
82
if err := ctx .Session .Start (ctx ); err != nil {
83
- log . Error (3 , "Failed to start session" , err )
83
+ ctx . Logger . Error ("Failed to start session" , "error " , err )
84
84
return false
85
85
}
86
86
@@ -91,7 +91,7 @@ func initContextWithUserSessionCookie(ctx *Context) bool {
91
91
92
92
query := m.GetSignedInUserQuery {UserId : userId }
93
93
if err := bus .Dispatch (& query ); err != nil {
94
- log . Error (3 , "Failed to get user with id %v " , userId )
94
+ ctx . Logger . Error ("Failed to get user with id" , "userId " , userId )
95
95
return false
96
96
} else {
97
97
ctx .SignedInUser = query .Result
@@ -185,7 +185,7 @@ func initContextWithApiKeyFromSession(ctx *Context) bool {
185
185
186
186
keyQuery := m.GetApiKeyByIdQuery {ApiKeyId : keyId .(int64 )}
187
187
if err := bus .Dispatch (& keyQuery ); err != nil {
188
- log . Error (3 , "Failed to get api key by id" , err )
188
+ ctx . Logger . Error ("Failed to get api key by id" , "id" , keyId , "error " , err )
189
189
return false
190
190
} else {
191
191
apikey := keyQuery .Result
@@ -202,7 +202,7 @@ func initContextWithApiKeyFromSession(ctx *Context) bool {
202
202
// Handle handles and logs error by given status.
203
203
func (ctx * Context ) Handle (status int , title string , err error ) {
204
204
if err != nil {
205
- log . Error (4 , "%s: %v" , title , err )
205
+ ctx . Logger . Error (title , "error" , err )
206
206
if setting .Env != setting .PROD {
207
207
ctx .Data ["ErrorMsg" ] = err
208
208
}
@@ -223,9 +223,7 @@ func (ctx *Context) Handle(status int, title string, err error) {
223
223
224
224
func (ctx * Context ) JsonOK (message string ) {
225
225
resp := make (map [string ]interface {})
226
-
227
226
resp ["message" ] = message
228
-
229
227
ctx .JSON (200 , resp )
230
228
}
231
229
@@ -237,7 +235,7 @@ func (ctx *Context) JsonApiErr(status int, message string, err error) {
237
235
resp := make (map [string ]interface {})
238
236
239
237
if err != nil {
240
- log . Error (4 , "%s: %v" , message , err )
238
+ ctx . Logger . Error (message , "error" , err )
241
239
if setting .Env != setting .PROD {
242
240
resp ["error" ] = err .Error ()
243
241
}
0 commit comments