Documentation ¶
Overview ¶
Package logs provides the low-level routines for directing log messages. It creates several logging channels for debug, info, errors, http, etc. These channels are directed to log files and/or stdout depending on how the application is configured. This package reads its configuration directly from a config file. In here you will find the log roatation config for rotatorr, panic redirection, and external logging methods.
Index ¶
- Variables
- type Cooler
- type LogConfig
- type Logger
- func (l *Logger) Close() (errors []error)
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(msg string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(msg string, v ...interface{})
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(msg string, v ...interface{})
- func (l *Logger) Rotate() (errors []error)
- func (l *Logger) SetupLogging(config *LogConfig)
- type Timer
Constants ¶
This section is empty.
Variables ¶
var (
ErrCloseCustom = fmt.Errorf("cannot close custom logs directly")
)
Custom errors.
Functions ¶
This section is empty.
Types ¶
type Cooler ¶
type Cooler struct {
// contains filtered or unexported fields
}
Cooler allows you to save/get if something is already running or not (active).
type LogConfig ¶ added in v0.1.6
type LogConfig struct { AppName string `json:"-"` LogFile string `json:"log_file" toml:"log_file" xml:"log_file" yaml:"log_file"` DebugLog string `json:"debug_log" toml:"debug_log" xml:"debug_log" yaml:"debug_log"` HTTPLog string `json:"http_log" toml:"http_log" xml:"http_log" yaml:"http_log"` LogFiles int `json:"log_files" toml:"log_files" xml:"log_files" yaml:"log_files"` LogFileMb int `json:"log_file_mb" toml:"log_file_mb" xml:"log_file_mb" yaml:"log_file_mb"` Debug bool `json:"debug" toml:"debug" xml:"debug" yaml:"debug"` Quiet bool `json:"quiet" toml:"quiet" xml:"quiet" yaml:"quiet"` }
LogConfig allows sending logs to rotating files. Setting an AppName will force log creation even if LogFile and HTTPLog are empty.
type Logger ¶
type Logger struct { ErrorLog *log.Logger // Shares a Writer with InfoLog. DebugLog *log.Logger // Shares a Writer with InfoLog by default. Changeable. InfoLog *log.Logger HTTPLog *log.Logger // contains filtered or unexported fields }
Logger provides some methods with baked in assumptions.
func CustomLog ¶ added in v0.1.6
CustomLog allows the creation of ad-hoc rotating log files from other packages. This is not thread safe with Rotate(), so do not call them at the same time.
func New ¶
func New() *Logger
New returns a new Logger with debug off and sends everything to stdout.
func (*Logger) Close ¶ added in v0.1.6
Close closes all open log files. Does not work on custom logs.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug writes log lines... to stdout and/or a file.
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error writes log lines... to stdout and/or a file.
func (*Logger) Print ¶
func (l *Logger) Print(v ...interface{})
Print writes log lines... to stdout and/or a file.
func (*Logger) Rotate ¶
Rotate rotates the log files. If called on a custom log, only rotates that log file.
func (*Logger) SetupLogging ¶
SetupLogging splits log writers into a file and/or stdout.