From 93db21104493269b3f7eb4034d5c3a46291366b4 Mon Sep 17 00:00:00 2001 From: STRRL Date: Tue, 15 Mar 2022 13:11:15 +0800 Subject: [PATCH] chore: append bootstrap logger with dependency injection Signed-off-by: STRRL --- text/2021-12-09-logging.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/text/2021-12-09-logging.md b/text/2021-12-09-logging.md index 086cf09..b637ccf 100644 --- a/text/2021-12-09-logging.md +++ b/text/2021-12-09-logging.md @@ -120,6 +120,17 @@ func doSomething() { > As you could see, it is actually a closure with an extern/global state. +With application using dependency injection framework (like `fx`), depends on +the different patterns for bootstrapping the application, there are several ways +to bootstrap the initialization of logger: + +- if only root logger is provided into dependency injection framework, using + another method that wraps the original constructor with the logic for setting + the logger name +- if various loggers are provided into dependency injection framework, using + another method that wraps the original constructor with "Named Values" feature + to inject the logger with a certain name. + ### Logging in Chaos Mesh Dashboard and gin Chaos Mesh Dashboard use [gin](https://github.com/gin-gonic/gin) as thew web