log

package
v0.0.0-...-42829d4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 59

Documentation

Overview

Usage:

import "github.com/baidu/go-lib/log"

// Two log files will be generated in ./log:
// test.log, and test.wf.log(for log > warn)
// The log will rotate, and there is support for backup count
log.Init("test", "INFO", "./log", true, "midnight", 5)

log.Logger.Warn("warn msg")
log.Logger.Info("info msg")

// it is required, to work around bug of log4go
time.Sleep(100 * time.Millisecond)

Index

Constants

This section is empty.

Variables

Logger is global logger

Functions

func Create

func Create(progName string, levelStr string, logDir string,
	hasStdOut bool, when string, backupCount int) (log4go.Logger, error)

Create creates log lib

PARAMS:

  • progName: program name. Name of log file will be progName.log
  • levelStr: "DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "CRITICAL"
  • logDir: directory for log. It will be created if noexist
  • hasStdOut: whether to have stdout output
  • when: "M", minute "H", hour "D", day "MIDNIGHT", roll over at midnight
  • backupCount: If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted.

func Init

func Init(progName string, levelStr string, logDir string,
	hasStdOut bool, when string, backupCount int) error

Init initializes log lib

PARAMS:

  • progName: program name. Name of log file will be progName.log
  • levelStr: "DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "CRITICAL"
  • logDir: directory for log. It will be created if noexist
  • hasStdOut: whether to have stdout output
  • when: "M", minute "H", hour "D", day "MIDNIGHT", roll over at midnight
  • backupCount: If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted.

func InitWithCompress

func InitWithCompress(progName string, levelStr string, logDir string,
	hasStdOut bool, when string, backupCount int, enableCompress bool) error

Init initializes log lib

PARAMS:

  • progName: program name. Name of log file will be progName.log
  • levelStr: "DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "CRITICAL"
  • logDir: directory for log. It will be created if noexist
  • hasStdOut: whether to have stdout output
  • when: "M", minute "H", hour "D", day "MIDNIGHT", roll over at midnight
  • backupCount: If backupCount is > 0, when rollover is done, no more than backupCount files are kept - the oldest ones are deleted.
  • enableCompress: whether to compress the roll over log file

func InitWithLogSvr

func InitWithLogSvr(progName string, levelStr string, loggerName string,
	network string, svrAddr string, svrAddrWf string,
	hasStdOut bool) error

InitWithLogSvr initializes log lib with remote log server

PARAMS:

  • progName: program name.
  • levelStr: "DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "CRITICAL"
  • loggerName: logger name
  • network: using "udp" or "unixgram"
  • svrAddr: remote unix sock address for all logger
  • svrAddrWf: remote unix sock address for warn/fatal logger If svrAddrWf is empty string, no warn/fatal logger will be created.
  • hasStdOut: whether to have stdout output

Types

This section is empty.

Directories

Path Synopsis
Package log4go provides level-based and highly configurable logging.
Package log4go provides level-based and highly configurable logging.

Jump to

Keyboard shortcuts

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