a geicko-2 based round robin ranking system designed to test c++ battleship submissions battleship.dunkirk.sh
1package log 2 3import "context" 4 5// WithContext wraps the given logger in context. 6func WithContext(ctx context.Context, logger *Logger) context.Context { 7 return context.WithValue(ctx, ContextKey, logger) 8} 9 10// FromContext returns the logger from the given context. 11// This will return the default package logger if no logger 12// found in context. 13func FromContext(ctx context.Context) *Logger { 14 if logger, ok := ctx.Value(ContextKey).(*Logger); ok { 15 return logger 16 } 17 return Default() 18} 19 20type contextKey struct{ string } 21 22// ContextKey is the key used to store the logger in context. 23var ContextKey = contextKey{"log"}