Categorygithub.com/cihub/seelog
modulepackage
0.0.0-20170130134532-f561c5e57575
Repository: https://github.com/cihub/seelog.git
Documentation: pkg.go.dev

# README

Seelog

Seelog is a powerful and easy-to-learn logging framework that provides functionality for flexible dispatching, filtering, and formatting log messages. It is natively written in the Go programming language.

Build Status

Features

  • Xml configuring to be able to change logger parameters without recompilation
  • Changing configurations on the fly without app restart
  • Possibility to set different log configurations for different project files and functions
  • Adjustable message formatting
  • Simultaneous log output to multiple streams
  • Choosing logger priority strategy to minimize performance hit
  • Different output writers
    • Console writer
    • File writer
    • Buffered writer (Chunk writer)
    • Rolling log writer (Logging with rotation)
    • SMTP writer
    • Others... (See Wiki)
  • Log message wrappers (JSON, XML, etc.)
  • Global variables and functions for easy usage in standalone apps
  • Functions for flexible usage in libraries

Quick-start

package main

import log "github.com/cihub/seelog"

func main() {
    defer log.Flush()
    log.Info("Hello from Seelog!")
}

Installation

If you don't have the Go development environment installed, visit the Getting Started document and follow the instructions. Once you're ready, execute the following command:

go get -u github.com/cihub/seelog

IMPORTANT: If you are not using the latest release version of Go, check out this wiki page

Documentation

Seelog has github wiki pages, which contain detailed how-tos references: https://github.com/cihub/seelog/wiki

Examples

Seelog examples can be found here: seelog-examples

Issues

Feel free to push issues that could make Seelog better: https://github.com/cihub/seelog/issues

Changelog

  • v2.6 : Config using code and custom formatters
    • Configuration using code in addition to xml (All internal receiver/dispatcher/logger types are now exported).
    • Custom formatters. Check wiki
    • Bugfixes and internal improvements.
  • v2.5 : Interaction with other systems. Part 2: custom receivers
    • Finished custom receivers feature. Check wiki
    • Added 'LoggerFromCustomReceiver'
    • Added 'LoggerFromWriterWithMinLevelAndFormat'
    • Added 'LoggerFromCustomReceiver'
    • Added 'LoggerFromParamConfigAs...'
  • v2.4 : Interaction with other systems. Part 1: wrapping seelog
    • Added configurable caller stack skip logic
    • Added 'SetAdditionalStackDepth' to 'LoggerInterface'
  • v2.3 : Rethinking 'rolling' receiver
    • Reimplemented 'rolling' receiver
    • Added 'Max rolls' feature for 'rolling' receiver with type='date'
    • Fixed 'rolling' receiver issue: renaming on Windows
  • v2.2 : go1.0 compatibility point [go1.0 tag]
    • Fixed internal bugs
    • Added 'ANSI n [;k]' format identifier: %EscN
    • Made current release go1 compatible
  • v2.1 : Some new features
    • Rolling receiver archiving option.
    • Added format identifier: %Line
    • Smtp: added paths to PEM files directories
    • Added format identifier: %FuncShort
    • Warn, Error and Critical methods now return an error
  • v2.0 : Second major release. BREAKING CHANGES.
    • Support of binaries with stripped symbols
    • Added log strategy: adaptive
    • Critical message now forces Flush()
    • Added predefined formats: xml-debug, xml-debug-short, xml, xml-short, json-debug, json-debug-short, json, json-short, debug, debug-short, fast
    • Added receiver: conn (network connection writer)
    • BREAKING CHANGE: added Tracef, Debugf, Infof, etc. to satisfy the print/printf principle
    • Bug fixes
  • v1.0 : Initial release. Features:
    • Xml config
    • Changing configurations on the fly without app restart
    • Contraints and exceptions
    • Formatting
    • Log strategies: sync, async loop, async timer
    • Receivers: buffered, console, file, rolling, smtp

# Packages

# Functions

Critical formats message using the default formats for its operands and writes to default logger with log level = Critical.
Criticalf formats message according to format specifier and writes to default logger with log level = Critical.
Debug formats message using the default formats for its operands and writes to default logger with log level = Debug.
Debugf formats message according to format specifier and writes to default logger with log level = Debug.
Error formats message using the default formats for its operands and writes to default logger with log level = Error.
Errorf formats message according to format specifier and writes to default logger with log level = Error.
Flush immediately processes all currently queued messages and all currently buffered messages.
Info formats message using the default formats for its operands and writes to default logger with log level = Info.
Infof formats message according to format specifier and writes to default logger with log level = Info.
LoggerFromConfigAsBytes creates a logger with config from bytes stream.
LoggerFromConfigAsFile creates logger with config from file.
LoggerFromConfigAsString creates a logger with config from a string.
LoggerFromCustomReceiver creates a proxy logger that uses a CustomReceiver as the receiver.
LoggerFromParamConfigAsBytes does the same as LoggerFromConfigAsBytes, but includes special parser options.
LoggerFromParamConfigAsFile does the same as LoggerFromConfigAsFile, but includes special parser options.
LoggerFromParamConfigAsString does the same as LoggerFromConfigAsString, but includes special parser options.
LoggerFromWriterWithMinLevel is shortcut for LoggerFromWriterWithMinLevelAndFormat(output, minLevel, DefaultMsgFormat).
LoggerFromWriterWithMinLevelAndFormat creates a proxy logger that uses io.Writer as the receiver with minimal level = minLevel and with specified format.
LoggerFromXMLDecoder creates logger with config from a XML decoder starting from a specific node.
LogLevelFromString parses a string and returns a corresponding log level, if sucessfull.
NewAsyncLoopLogger creates a new asynchronous adaptive logger.
NewAsyncLoopLogger creates a new asynchronous loop logger.
NewAsyncLoopLogger creates a new asynchronous loop logger.
NewBufferedWriter creates a new buffered writer struct.
Creates writer to the address addr on the network netName.
Creates a new console writer.
NewCustomReceiverDispatcher creates a customReceiverDispatcher which dispatches data to a specific receiver created using a <custom> tag in the config file.
NewCustomReceiverDispatcherByValue is basically the same as NewCustomReceiverDispatcher, but using a specific CustomReceiver value instead of instantiating a new one by type.
Creates a new file and a corresponding writer.
NewFilterDispatcher creates a new filterDispatcher using a list of allowed levels.
NewFormatter creates a new formatter using a format string.
NewListConstraints creates a new listConstraints struct with the specified allowed levels.
NewLogLevelException creates a new exception.
NewMinMaxConstraints creates a new minMaxConstraints struct with the specified min and max levels.
NewSMTPWriter returns a new SMTP-writer.
NewSyncLogger creates a new synchronous logger.
RegisterCustomFormatter registers a new custom formatter factory with a given name.
RegisterReceiver records a custom receiver type, identified by a value of that type (second argument), under the specified name.
ReplaceLogger acts as UseLogger but the logger that was previously used is disposed (except Default and Disabled loggers).
Trace formats message using the default formats for its operands and writes to default logger with log level = Trace.
Tracef formats message according to format specifier and writes to default logger with log level = Trace.
UseLogger sets the 'Current' package level logger variable to the specified value.
Warn formats message using the default formats for its operands and writes to default logger with log level = Warn.
Warnf formats message according to format specifier and writes to default logger with log level = Warn.

# Constants

Log levels.
Log level string representations (used in configuration files).
Time and date formats used for %Date and %Time aliases.
Log levels.
Log level string representations (used in configuration files).
Default subject phrase for sending emails.
Log levels.
Log level string representations (used in configuration files).
FormatterSymbol is a special symbol used in config files to mark special format aliases.
Log levels.
Log level string representations (used in configuration files).
MaxQueueSize is the critical number of messages in the queue that result in an immediate flush.
Log levels.
Log level string representations (used in configuration files).
Time and date formats used for %Date and %Time aliases.
Log levels.
Log level string representations (used in configuration files).
Log levels.
Log level string representations (used in configuration files).

# Variables

Current is the logger used in all package level convenience funcs like 'Trace', 'Debug', 'Flush', etc.
Default logger that is created from an empty config: "<seelog/>".
Disabled logger that doesn't produce any output in any circumstances.

# Structs

CfgParseParams represent specific parse options or flags used by parser.
CustomReceiverInitArgs represent arguments passed to the CustomReceiver.Init func when custom receiver is being initialized.
LogLevelException represents an exceptional case used when you need some specific files or funcs to override general constraints and to use their own.

# Interfaces

CustomReceiver is the interface that external custom seelog message receivers must implement in order to be able to process seelog messages.
Represents runtime caller context.
LoggerInterface represents structs capable of logging Seelog messages.

# Type aliases

CustomReceiverProducer is the signature of the function CfgParseParams needs to create custom receivers.
FormatterFunc represents one formatter object that starts with '%' sign in the 'format' attribute of the 'format' config item.
FormatterFuncCreator is a factory of FormatterFunc objects.
Log level type.