mlog: github.com/jbrodriguez/mlog Index | Files

package mlog

import "github.com/jbrodriguez/mlog"

Package mlog is simple logging module for go, with a rotating file feature and console logging.

Index

Package Files

mlog.go

Constants

const BackupCount int = 10
const MaxBytes int = 10 * 1024 * 1024

Variables

var DefaultFlags = log.Ldate | log.Ltime | log.Lshortfile

DefaultFlags used by created loggers

var Logger mlog

func Error Uses

func Error(err error)

Error writes to the Error destination and accepts an err

func Fatal Uses

func Fatal(a ...interface{})

Fatal writes to the Fatal destination and exits with an error 255 code

func FatalIfError Uses

func FatalIfError(err error)

FatalIfError is a shortcut function for log.Fatalf if error and exits with an error 255 code

func Fatalf Uses

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

Fatalf writes to the Fatal destination and exits with an error 255 code

func IfError Uses

func IfError(err error)

IfError is a shortcut function for log.Error if error

func Info Uses

func Info(format string, a ...interface{})

Info writes to the Info destination

func Start Uses

func Start(level LogLevel, path string)

Start starts the logging

func StartEx Uses

func StartEx(level LogLevel, path string, maxBytes, backupCount int)

func Stop Uses

func Stop() error

Stop stops the logging

func Sync Uses

func Sync()

Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.

func Trace Uses

func Trace(format string, a ...interface{})

Trace writes to the Trace destination

func Warning Uses

func Warning(format string, a ...interface{})

Warning writes to the Warning destination

type LogLevel Uses

type LogLevel int32

LogLevel type

const (
    // LevelTrace logs everything
    LevelTrace LogLevel = (1 << iota)

    // LevelInfo logs Info, Warnings and Errors
    LevelInfo

    // LevelWarn logs Warning and Errors
    LevelWarn

    // LevelError logs just Errors
    LevelError
)

type RotatingFileHandler Uses

type RotatingFileHandler struct {
    // contains filtered or unexported fields
}

RotatingFileHandler writes log a file, if file size exceeds maxBytes, it will backup current file and open a new one.

max backup file number is set by backupCount, it will delete oldest if backups too many.

func NewRotatingFileHandler Uses

func NewRotatingFileHandler(fileName string, maxBytes int, backupCount int) (*RotatingFileHandler, error)

NewRotatingFileHandler creates dirs and opens the logfile

func (*RotatingFileHandler) Close Uses

func (h *RotatingFileHandler) Close() error

Close simply closes the File

func (*RotatingFileHandler) Write Uses

func (h *RotatingFileHandler) Write(p []byte) (n int, err error)

Package mlog imports 7 packages (graph) and is imported by 5 packages. Updated 2018-08-07. Refresh now. Tools for package owners.