log

package module
v0.0.0-...-62a3dc9 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: BSD-2-Clause Imports: 9 Imported by: 2

README

Log

Build Status

Build Status

Overview

Log is a Go package which provides logging interfaces and common implementations.

Flog

Flog is a submodule which provides file-backed logging capabilities for go applications. FLog is built on top of the standard log library, and includes facilities for buffered logging, managing separate logs and log files, as well as periodic log rotation.

License

These Go packages are released under a BSD-style license, the contents of which are in the repo's LICENSE file.

API Documentation

http://godoc.org/github.com/xaevman/log http://godoc.org/github.com/xaevman/flog

Documentation

Overview

Package log provides interfaces, basic types and formatting helpers for common application logging tasks.

Index

Constants

This section is empty.

Variables

View Source
var ConsoleLogger = &ConsoleLog{}
View Source
var NullLogger = &NullLog{}

Functions

This section is empty.

Types

type ConsoleLog

type ConsoleLog struct{}

func (*ConsoleLog) Debug

func (nl *ConsoleLog) Debug(format string, v ...interface{})

func (*ConsoleLog) Error

func (nl *ConsoleLog) Error(format string, v ...interface{})

func (*ConsoleLog) Info

func (nl *ConsoleLog) Info(format string, v ...interface{})

func (*ConsoleLog) Print

func (nl *ConsoleLog) Print(msg *LogMsg)

type DebugLogger

type DebugLogger interface {
	Debug(format string, v ...interface{})
}

type ErrorLogger

type ErrorLogger interface {
	Error(format string, v ...interface{})
}

type InfoLogger

type InfoLogger interface {
	Info(format string, v ...interface{})
}

type LogBuffer

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

LogBuffer holds a specified number of logs in memory for rendering by the http logs Uri.

func NewLogBuffer

func NewLogBuffer(maxSize int) *LogBuffer

NewLogBuffer returns a pointer to a new LogBuffer instance.

func (*LogBuffer) HasChanged

func (this *LogBuffer) HasChanged() bool

HasChanged reports whether or not the buffer has been modified since it was last read.

func (*LogBuffer) MarshalJSON

func (this *LogBuffer) MarshalJSON() ([]byte, error)

MarshalJSON implements the standard go json marshaler for the LogBuffer type.

func (*LogBuffer) Print

func (this *LogBuffer) Print(msg *LogMsg)

Print formats and adds a new message to the log buffer. If the new message causes the log buffer to grow larger than its maxSize, it truncates the end oldest entry in the buffer. Once the message is stored, the changed flag is set to true.

func (*LogBuffer) ReadAll

func (this *LogBuffer) ReadAll() []*LogMsg

ReadAll returns a list of all log messages currently in the buffer.

func (*LogBuffer) SetEnabled

func (this *LogBuffer) SetEnabled(enabled bool)

SetEnabled temporarily enables/disables the logger.

type LogCloser

type LogCloser interface {
	Close()
}

LogCloser represents the interface for a closable log object, such as those provided by file-backed logging.

type LogMsg

type LogMsg struct {
	Timestamp time.Time
	Name      string
	File      string
	Line      int
	Message   string
}

func NewLogMsg

func NewLogMsg(name, format string, callDepth int, v ...interface{}) *LogMsg

NewLogMsg generates a log object given the standard logging format yyyy/mm/dd MM:HH:SS.ssssss [NAME] <file:line> msg

func (*LogMsg) String

func (this *LogMsg) String() string

type LogNotify

type LogNotify interface {
	Print(msg *LogMsg)
}

Log represents the interface for a generalized log object.

type LogToggler

type LogToggler interface {
	SetEnabled(bool)
}

LogToggler represents the interface needed to temporarily enabled/disable a given logger.

type NullLog

type NullLog struct{}

func (*NullLog) Debug

func (nl *NullLog) Debug(format string, v ...interface{})

func (*NullLog) Error

func (nl *NullLog) Error(format string, v ...interface{})

func (*NullLog) Info

func (nl *NullLog) Info(format string, v ...interface{})

func (*NullLog) Print

func (nl *NullLog) Print(msg *LogMsg)

Directories

Path Synopsis
Package flog provides facilities for using and managing file-backed logger objects.
Package flog provides facilities for using and managing file-backed logger objects.

Jump to

Keyboard shortcuts

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