logrus_log

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT Imports: 12 Imported by: 11

README

logrus_log

logrus_log implement the log interface
support both linux mac andwindows
install
go get "github.com/universe-30/logrus_log"
example
package main

import (
	"github.com/coreservice-io/log"
	"github.com/coreservice-io/logrus_log"
)

func main() {
	//default is info level
	//return the log interface implemented instance

	// if need to log to file
	llog, err := logrus_log.NewWithFile("./logs", 1, 20, 30)
	// if do not want to log to file, only log to console
	//  llog, err := logrus_log.New()
	if err != nil {
		panic(err.Error())
	}

	llog.SetLevel(log.TraceLevel)

	llog.Traceln("trace log")
	llog.Debugln("debug log")
	llog.Infoln("info log")
	llog.Warnln("warn log")
	llog.Errorln("error log")
	//log.Fatalln("fatal log")
	//log.Panicln("panic log")

	llog.PrintLastN(100, []log.LogLevel{log.ErrorLevel, log.InfoLevel})
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (log.Logger, error)

func NewWithFile added in v0.2.2

func NewWithFile(logsAbsFolder string, fileMaxSizeMBytes int, MaxBackupsFiles int, MaxAgeDays int) (log.Logger, error)

Default is info level

Types

type Fields

type Fields = logrus.Fields

type LocalLog

type LocalLog struct {
	*logrus.Logger

	ALL_LogfolderABS string
	ERR_LogfolderABS string
	MaxSize          int
	MaxBackups       int
	MaxAge           int
	// contains filtered or unexported fields
}

func (*LocalLog) GetLastN

func (logger *LocalLog) GetLastN(lineCount int64, levels []LogLevel) ([]string, error)

func (*LocalLog) GetLevel

func (logger *LocalLog) GetLevel() log.LogLevel

func (*LocalLog) PrintLastN

func (logger *LocalLog) PrintLastN(lineCount int64, levels []LogLevel)

func (*LocalLog) SetLevel

func (logger *LocalLog) SetLevel(loglevel LogLevel)

type LogLevel

type LogLevel = log.LogLevel

type UTCFormatter

type UTCFormatter struct {
	logrus.Formatter
}

func (UTCFormatter) Format

func (u UTCFormatter) Format(e *logrus.Entry) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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