packagelogsimport("fmt""testing""github.com/astaxie/beego/pkg/infrastructure/utils")funccustomFormatter(lm*LogMsg)string{returnfmt.Sprintf("[CUSTOM CONSOLE LOGGING] %s",lm.Msg)}funcglobalFormatter(lm*LogMsg)string{returnfmt.Sprintf("[GLOBAL] %s",lm.Msg)}funcTestCustomLoggingFormatter(t*testing.T){// beego.BConfig.Log.AccessLogs = trueSetLoggerWithOpts("console",[]string{`{"color":true}`},&utils.SimpleKV{Key:"formatter",Value:customFormatter})// Message will be formatted by the customFormatter with colorful text set to trueInformational("Test message")}funcTestGlobalLoggingFormatter(t*testing.T){SetGlobalFormatter(globalFormatter)SetLogger("console",`{"color":true}`)// Message will be formatted by globalFormatterInformational("Test message")}