simplelog

package module
v1.0.0-...-944c5dd Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2014 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Go Simple Logger

A simple logger that wraps log and log/syslog into something consistent and easy to use.

Build Status

Example

Declare the logger:

logger, _ := simplelog.NewLogger(simplelog.CONSOLE | simplelog.SYSLOG, "example")

Send logs to it:

logger.Notice("starting the app")

Set the level:

logger.SetLevel(simplelog.DEBUG)
logger.Debug("this is not a traceback")

Close the logger:

logger.Close()

License

Copyright (c) 2014 Ryan Bourgeois. Licensed under BSD-Modified. See the LICENSE file for a copy of the license.

Documentation

Index

Constants

View Source
const (
	SYSLOG = 1 << iota
	CONSOLE
)
View Source
const (
	DEBUG = iota
	INFO
	NOTICE
	WARN
	ERROR
	FATAL
)

Variables

This section is empty.

Functions

func LevelToString

func LevelToString(level int) string

Get a string for a level value.

func StringToLevel

func StringToLevel(level string) int

Get a level for a string value.

Types

type Logger

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

Simple logger instance.

func NewLogger

func NewLogger(outputs int, prefix string) (l *Logger, err error)

Create a new logger with the given outputs and log prefix. Level is set up INFO.

func (*Logger) Close

func (l *Logger) Close() (err error)

Close the logger.

func (*Logger) Console

func (l *Logger) Console() bool

Check if console logging is enabled.

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{}) error

Log to DEBUG level.

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{}) error

Log to ERROR level.

func (*Logger) Fatal

func (l *Logger) Fatal(format string, args ...interface{}) error

Log to FATAL level.

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{}) error

Log to INFO level.

func (*Logger) Log

func (l *Logger) Log(level int, format string, args ...interface{}) (err error)

Log to all configured outputs.

func (*Logger) Notice

func (l *Logger) Notice(format string, args ...interface{}) error

Log to NOTICE level.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

Set the logging level.

func (*Logger) Syslog

func (l *Logger) Syslog() bool

Check if syslog logging is enabled.

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{}) error

Log to WARN level.

Jump to

Keyboard shortcuts

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