log

package
v0.0.0-...-ba7cdbd Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2014 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package log implements low-level logging.

Users should not use this package directly. Instead, the gnd.la/app.Context.Logger method should be used to obtain an Interface to log messages.

Index

Constants

View Source
const (
	// Bits or'ed together to control what's printed. There is no control over the
	// order they appear (the order listed here) or the format they present (as
	// described in the comments).  A colon appears after these items:
	//	2009/0123 01:23:23.123123 /a/b/c/d.go:23: message
	Ldate         = 1 << iota                              // the date: 2009/01/23
	Ltime                                                  // the time: 01:23:23
	Lmicroseconds                                          // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                                              // full file name and line number: /a/b/c/d.go:23
	Lshortfile                                             // final file name element and line number: d.go:23. overrides Llongfile
	Llevel                                                 // preprend the message level
	Lshortlevel                                            // preprend the abbreviated message level (overrides Llevel)
	Lcolored                                               // uses colors around the level name
	LstdFlags     = Ldate | Ltime | Lshortlevel | Lcolored // initial values for the standard logger

)

These flags define which text to prefix to each log entry generated by the Logger.

Variables

Functions

func Debug

func Debug(v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func Debugln

func Debugln(v ...interface{})

func Error

func Error(v ...interface{})

func Errorf

func Errorf(format string, v ...interface{})

func Errorln

func Errorln(v ...interface{})

func Fatal

func Fatal(v ...interface{})

Fatal is equivalent to Print() followed by a call to os.Exit(1).

func Fatalf

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

Fatalf is equivalent to Printf() followed by a call to os.Exit(1).

func Fatalln

func Fatalln(v ...interface{})

Fatalln is equivalent to Println() followed by a call to os.Exit(1).

func Flags

func Flags() int

Flags returns the output flags for the standard logger.

func Info

func Info(v ...interface{})

func Infof

func Infof(format string, v ...interface{})

func Infoln

func Infoln(v ...interface{})

func Log

func Log(level LLevel, v ...interface{})

These functions write to the standard logger.

func Logf

func Logf(level LLevel, format string, v ...interface{})

func Logln

func Logln(level LLevel, v ...interface{})

func Nil

func Nil(v interface{})

Nil does nothing if the argument is nil. Otherwise, it's equivalent to Panic().

func Panic

func Panic(v ...interface{})

Panic is equivalent to Print() followed by a call to panic().

func Panicf

func Panicf(format string, v ...interface{})

Panicf is equivalent to Printf() followed by a call to panic().

func Panicln

func Panicln(v ...interface{})

Panicln is equivalent to Println() followed by a call to panic().

func Print

func Print(v ...interface{})

Print calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Print.

func Printf

func Printf(format string, v ...interface{})

Printf calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Printf.

func Println

func Println(v ...interface{})

Println calls Output to print to the standard logger. Arguments are handled in the manner of fmt.Println.

func SetFlags

func SetFlags(flag int)

SetFlags sets the output flags for the standard logger.

func SetLevel

func SetLevel(level LLevel)

func SetOutput

func SetOutput(out Writer)

AddWriter adds a writer to the standard logger for the standard logger.

func Warning

func Warning(v ...interface{})

func Warningf

func Warningf(format string, v ...interface{})

func Warningln

func Warningln(v ...interface{})

Types

type IOWriter

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

func NewIOWriter

func NewIOWriter(out io.Writer, level LLevel) *IOWriter

func (*IOWriter) Level

func (w *IOWriter) Level() LLevel

func (*IOWriter) Write

func (w *IOWriter) Write(level LLevel, flags int, b []byte) (int, error)

type Interface

type Interface interface {
	// Debug formats its arguments like fmt.Print and records a
	// log message at the debug level.
	Debug(args ...interface{})
	// Debugf formats its arguments like fmt.Printf and records a
	// log message at the debug level.
	Debugf(format string, args ...interface{})

	// Info formats its arguments like fmt.Print and records a
	// log message at the info level.
	Info(args ...interface{})
	// Infof formats its arguments like fmt.Printf and records a
	// log message at the info level.
	Infof(format string, args ...interface{})

	// Warning formats its arguments like fmt.Print and records a
	// log message at the warning level.
	Warning(args ...interface{})
	// Warningf formats its arguments like fmt.Printf and records a
	// log message at the warning level.
	Warningf(format string, args ...interface{})

	// Error formats its arguments like fmt.Print and records a
	// log message at the error level.
	Error(args ...interface{})
	// Errorf formats its arguments like fmt.Printf and records a
	// log message at the error level.
	Errorf(format string, args ...interface{})
}

Interface is the interface implemented by any logger in Gondola.

type LLevel

type LLevel int
const (
	LDebug LLevel = iota
	LInfo
	LWarning
	LError
	LPanic
	LFatal
	LNone
	LDefault = LInfo
)

func Level

func Level() LLevel

func (LLevel) Colorcode

func (l LLevel) Colorcode() string

func (LLevel) Initial

func (l LLevel) Initial() string

func (LLevel) String

func (l LLevel) String() string

type Logger

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

A Logger represents an active logging object that generates lines of output to an io.Writer. Each logging operation makes a single call to the Writer's Write method. A Logger can be used simultaneously from multiple goroutines; it guarantees to serialize access to the Writer.

func New

func New(out Writer, flags int, level LLevel) *Logger

New creates a new Logger. The out variable sets the destination to which log data will be written. The flag argument defines the logging properties.

func (*Logger) AddWriter

func (l *Logger) AddWriter(w Writer)

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

func (*Logger) Debugln

func (l *Logger) Debugln(v ...interface{})

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

func (*Logger) Errorln

func (l *Logger) Errorln(v ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

Fatal is equivalent to l.Print() followed by a call to os.Exit(1).

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1).

func (*Logger) Fatalln

func (l *Logger) Fatalln(v ...interface{})

Fatalln is equivalent to l.Println() followed by a call to os.Exit(1).

func (*Logger) Flags

func (l *Logger) Flags() int

Flags returns the output flags for the logger.

func (*Logger) FormatMessage

func (l *Logger) FormatMessage(level LLevel, calldepth int, s string) []byte

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

func (*Logger) Infoln

func (l *Logger) Infoln(v ...interface{})

func (*Logger) IsDebug

func (l *Logger) IsDebug() bool

IsDebug returns true if the Logger is showing debug messages.

func (*Logger) Level

func (l *Logger) Level() LLevel

func (*Logger) Log

func (l *Logger) Log(level LLevel, v ...interface{})

func (*Logger) Logf

func (l *Logger) Logf(level LLevel, format string, v ...interface{})

func (*Logger) Logln

func (l *Logger) Logln(level LLevel, v ...interface{})

func (*Logger) Nil

func (l *Logger) Nil(v interface{})

Nil does nothing if the argument is nil. Otherwise, it's equivalent to Panic().

func (*Logger) Panic

func (l *Logger) Panic(v ...interface{})

Panic is equivalent to l.Print() followed by a call to panic().

func (*Logger) Panicf

func (l *Logger) Panicf(format string, v ...interface{})

Panicf is equivalent to l.Printf() followed by a call to panic().

func (*Logger) Panicln

func (l *Logger) Panicln(v ...interface{})

Panicln is equivalent to l.Println() followed by a call to panic().

func (*Logger) Print

func (l *Logger) Print(v ...interface{})

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

func (*Logger) Println

func (l *Logger) Println(v ...interface{})

func (*Logger) RemoveWriters

func (l *Logger) RemoveWriters()

func (*Logger) SetFlags

func (l *Logger) SetFlags(flags int)

SetFlags sets the output flags for the logger.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LLevel)

func (*Logger) Warning

func (l *Logger) Warning(v ...interface{})

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...interface{})

func (*Logger) Warningln

func (l *Logger) Warningln(v ...interface{})

func (*Logger) Write

func (l *Logger) Write(level LLevel, calldepth int, v ...interface{})

Write is a generic low-level interface to a Logger. By using the calldepth parameters, wrappers can define their own functions which correctly obtain the PC for the callers (otherwise, all the calls to the logging would appear as coming from the wrapper.

func (*Logger) Writef

func (l *Logger) Writef(level LLevel, calldepth int, format string, v ...interface{})

func (*Logger) Writeln

func (l *Logger) Writeln(level LLevel, calldepth int, v ...interface{})

type SmtpWriter

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

func NewSmtpWriter

func NewSmtpWriter(level LLevel, server, from, to string) *SmtpWriter

func (*SmtpWriter) Level

func (w *SmtpWriter) Level() LLevel

func (*SmtpWriter) Write

func (w *SmtpWriter) Write(level LLevel, flags int, b []byte) (int, error)

type Writer

type Writer interface {
	Write(LLevel, int, []byte) (int, error)
	Level() LLevel
}

Jump to

Keyboard shortcuts

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