logger

package
v0.0.0-...-130f5e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2018 License: Apache-2.0 Imports: 1 Imported by: 30

README

日志

级别
  • Trace(args ...interface{}) 打印trace级别日志

  • Debug(args ...interface{}) Debug 打印debug级别日志

  • Info(args ...interface{}) 打印info级别日志

  • Warn(args ...interface{}) 打印warn级别日志

  • Error(args ...interface{}) 打印error级别日志

  • Fatal(args ...interface{}) 打印critial级别日志

  • Tracef(format string, args ...interface{}) 打印trace级别日志

  • Debugf(format string, args ...interface{}) Debug 打印debug级别日志

  • Infof(format string, args ...interface{}) 打印info级别日志

  • Warnf(format string, args ...interface{}) 打印warn级别日志

  • Errorf(format string, args ...interface{}) 打印error级别日志

  • Fatalf(format string, args ...interface{}) 打印critial级别日志

配置
  • 日志配置方法
func ConfigAsFile(filename string) error

注意: 不调用配置方法,日志默认打印到终端。

  • 配置日志打印到文件
<seelog>
    <outputs>
        <file path="test.log"/>
    </outputs>
</seelog>
代码示例
package main

import "git.oschina.net/cloudzone/smartgo/stgcommon/logger"

func main() {
	console()
}

func console() {
	logger.Trace("this is a test")
	logger.Debug("this is a test")
	logger.Info("this is a test")
	logger.Warn("this is a test")
	logger.Error("this is a test")
	logger.Fatal("this is a test")

	logger.Tracef("this is a %s", "test")
	logger.Debugf("this is a %s", "test")
	logger.Infof("this is a %s", "test")
	logger.Warnf("this is a %s", "test")
	logger.Errorf("this is a %s", "test")
	logger.Fatalf("this is a %s", "test")
}
package main

import "git.oschina.net/cloudzone/smartgo/stgcommon/logger"

func main() {
	file()
}

func file() {
	logger.ConfigAsFile("seelog.xml")

	logger.Trace("this is a test")
	logger.Debug("this is a test")
	logger.Info("this is a test")
	logger.Warn("this is a test")
	logger.Error("this is a test")
	logger.Fatal("this is a test")

	logger.Tracef("this is a %s", "test")
	logger.Debugf("this is a %s", "test")
	logger.Infof("this is a %s", "test")
	logger.Warnf("this is a %s", "test")
	logger.Errorf("this is a %s", "test")
	logger.Fatalf("this is a %s", "test")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigAsFile

func ConfigAsFile(filename string) error

ConfigAsFile 配置文件

func Debug

func Debug(args ...interface{})

Debug 打印debug级别日志

func Debugf

func Debugf(format string, args ...interface{})

Debug 打印debug级别日志

func Error

func Error(args ...interface{})

Error 打印error级别日志

func Errorf

func Errorf(format string, args ...interface{})

Error 打印error级别日志

func Fatal

func Fatal(args ...interface{})

Fatal 打印critial级别日志

func Fatalf

func Fatalf(format string, args ...interface{})

Fatal 打印critial级别日志

func Flush

func Flush()

Flush 刷新日志

func Info

func Info(args ...interface{})

Info 打印info级别日志

func Infof

func Infof(format string, args ...interface{})

Info 打印info级别日志

func Trace

func Trace(args ...interface{})

Trace 打印trace级别日志

func Tracef

func Tracef(format string, args ...interface{})

Trace 打印trace级别日志

func Warn

func Warn(args ...interface{})

Warn 打印warn级别日志

func Warnf

func Warnf(format string, args ...interface{})

Warn 打印warn级别日志

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL