Skip to content

自定义日志组件

Joe Zou edited this page Sep 16, 2020 · 7 revisions

参考实现

复制以下代码至项目中,并在其中引用日志组件的方法进行打印log

type DefaultLogger struct {
}

func (this *DefaultLogger)Debugf(format string, params ...interface{})  {
	
}

func (this *DefaultLogger)Infof(format string, params ...interface{}) {

}


func (this *DefaultLogger)Warnf(format string, params ...interface{}) error {
	return nil
}

func (this *DefaultLogger)Errorf(format string, params ...interface{}) error {
	return nil
}


func (this *DefaultLogger)Debug(v ...interface{}) {

}
func (this *DefaultLogger)Info(v ...interface{}){

}

func (this *DefaultLogger)Warn(v ...interface{}) error{
	return nil
}

func (this *DefaultLogger)Error(v ...interface{}) error{
	return nil
}

启动

func main() {
   agollo.SetLogger(&DefaultLogger{})
   client,e:=agollo.Start()
}

更多信息:https://github.com/zouyx/agollo_demo/tree/master/custom/log