log: remove log "module" system
After comtemplation, the complexity of the logging module system outweighs its usefulness. This changeset removes the system and restores lighter weight code paths. As a concession, we can always provide more context when necessary to log messages to understand them without having to fork the context for a certain set of calls. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -16,26 +16,3 @@ func TestLoggerContext(t *testing.T) {
|
||||
assert.Equal(t, GetLogger(ctx).Data["test"], "one")
|
||||
assert.Equal(t, G(ctx), GetLogger(ctx)) // these should be the same.
|
||||
}
|
||||
|
||||
func TestModuleContext(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
assert.Equal(t, GetModulePath(ctx), "")
|
||||
|
||||
ctx = WithModule(ctx, "a") // basic behavior
|
||||
assert.Equal(t, GetModulePath(ctx), "a")
|
||||
logger := GetLogger(ctx)
|
||||
assert.Equal(t, logger.Data["module"], "a")
|
||||
|
||||
parent, ctx := ctx, WithModule(ctx, "a")
|
||||
assert.Equal(t, ctx, parent) // should be a no-op
|
||||
assert.Equal(t, GetModulePath(ctx), "a")
|
||||
assert.Equal(t, GetLogger(ctx).Data["module"], "a")
|
||||
|
||||
ctx = WithModule(ctx, "b") // new module
|
||||
assert.Equal(t, GetModulePath(ctx), "a/b")
|
||||
assert.Equal(t, GetLogger(ctx).Data["module"], "a/b")
|
||||
|
||||
ctx = WithModule(ctx, "c") // new module
|
||||
assert.Equal(t, GetModulePath(ctx), "a/b/c")
|
||||
assert.Equal(t, GetLogger(ctx).Data["module"], "a/b/c")
|
||||
}
|
||||
|
Reference in New Issue
Block a user