You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ron Zhang db9af169a6 Migrate to gitera.cn 2 years ago
example Migrate to gitera.cn 2 years ago
.gitignore Implement log file scrolling and gzip log file 4 years ago
LICENSE Add LICENSE 4 years ago
README.md Migrate to gitera.cn 2 years ago
config.go Rename package 2 years ago
console_logger.go Migrate to gitera.cn 2 years ago
file_logger.go Migrate to gitera.cn 2 years ago
file_logger_test.go Migrate to gitera.cn 2 years ago
formatter.go Rename package 2 years ago
go.mod Migrate to gitera.cn 2 years ago
go.sum Migrate to gitera.cn 2 years ago
json_formatter.go Replace 'xorm.io/xorm/log' with 'github.com/ronzxy/go-xorm/log' 2 years ago
logger.go Migrate to gitera.cn 2 years ago
logger_test.go Migrate to gitera.cn 2 years ago
logger_writer.go Migrate to gitera.cn 2 years ago
text_formatter.go Migrate to gitera.cn 2 years ago
util.go Migrate to gitera.cn 2 years ago
writer.go Migrate to gitera.cn 2 years ago

README.md

go-logger

Go Report Card GoDoc Github All Releases GitHub release GitHub Release Date GitHub license GitHub stars GitHub forks Sourcegraph

Description

A log library for golang. Can be initialized from xml format configuration file, supports scrolling based on file size and time of log files.

Installation

This package can be installed with the go get command:

    go get gitera.cn/ron/go-logger

Logger Level

    ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < OFF

Initialized

LoggerWriter is a complete logger that supports automatic scrolling of logger files by time or file size. It's initial by config file with xml format "example/logger.xml":

package main

import (
    "gitera.cn/ron/go-logger"
)

func main()  {
    err := logger.Init("example/logger.xml")

    if err != nil {
        logger.DefaultConsoleLogger().Error(err.Error())
        return
    }

    logger.Trace("Test Logger trace message")
    logger.Debug("Test Logger debug message")
    logger.Info("Test Logger info message")
    logger.Warn("Test Logger warn message")
    logger.Error("Test Logger error message")
}

ConsoleLogger

Console logger outputs log information to stdout:

package main

import (
    "gitera.cn/ron/go-logger"
)

func main()  {
    consoleLogger := logger.NewConsoleLogger(logger.ALL)

    consoleLogger.Info("ConsoleLogger info message") 
}

FileLogger

File logger outputs log information to a file:

package main

import (
    "gitera.cn/ron/go-logger"
)

func main()  {
    fileLogger, err := logger.NewFileLogger(logger.ALL, "logs/fileLogger.log")
    if err != nil {
        logger.DefaultConsoleLogger().Error(err.Error())
        return
    }

    fileLogger.Info("FileLogger info message")
}