-
-
Save justonia/f81eead323d2b23eca1c485ed8e5db5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Log call at point of error: | |
func BreedDragons(ctx context.Context, game *GameKey) error { | |
// See 'category' in the json blob below. This adds a new category | |
// to the stack, but in the log below we are able to see what methods | |
// actually made the call into this method. | |
ctx = logging.AddCategory(ctx, "breeddragons") | |
// logic... | |
// Notice that only the error and a small message are provided. | |
if err != nil { | |
logging.Error(ctx, err, "falling back to drg_fire") | |
return err | |
} | |
} | |
Logging package API (simplified): | |
func Error(ctx context.Context, err error, args ...interface{}) { | |
category := CategoryFrom(ctx) | |
if log, ok := ctx.Value(LoggerKey).(Logger); ok { | |
log.Write(ERROR, category, buildArgs(ctx, append([]interface{}{err}, args...)...)) | |
} | |
} | |
Data that ends up in logging backend: | |
{ | |
"build": "DV2-IP16-13", | |
"category": "frontend:dv2:breeddragons", | |
"cv": "1.1.0.1010-master", | |
"error": { | |
"message": "ServiceError({Code:ServiceErrorCode_InternalServerError CategorySource:frontend:dv2:breeddragons Msg:falling back to drg_fire ServerErrorType:*errors.errorString})", | |
"type": "*core.ServiceError" | |
}, | |
"game": "dv2", | |
"host": "ab0844ae1d22", | |
"level": "ERROR", | |
"ref": "nBu8KzCN5GyHQftI5YT7JQ", | |
"request_id": "b5c3bcae-ebea-41aa-9b1f-79328733c86b", | |
"request_phase": "in-progress", | |
"service": "dv2", | |
"sid": "f7b7d7f1-4f44-45fe-9188-41799bcea735", | |
"timestamp": "2016-05-02T12:29:55.141288Z", | |
"url_path": "/service" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment