maubot/vendor/maunium.net/go/maulogger/defaults.go

270 lines
10 KiB
Go
Raw Normal View History

2018-07-06 13:31:42 +00:00
// mauLogger - A logger for Go programs
2018-09-19 22:28:37 +00:00
// Copyright (C) 2016-2018 Tulir Asokan
2018-07-06 13:31:42 +00:00
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2018-09-19 22:28:37 +00:00
//
2018-07-06 13:31:42 +00:00
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2018-09-19 22:28:37 +00:00
//
2018-07-06 13:31:42 +00:00
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package maulogger
import (
"os"
)
// DefaultLogger ...
2018-09-19 22:28:37 +00:00
var DefaultLogger = Create().(*BasicLogger)
2018-07-06 13:31:42 +00:00
2018-09-19 22:28:37 +00:00
// SetWriter formats the given parts with fmt.Sprint and logs the result with the SetWriter level
2018-07-06 13:31:42 +00:00
func SetWriter(w *os.File) {
DefaultLogger.SetWriter(w)
}
2018-09-19 22:28:37 +00:00
// OpenFile formats the given parts with fmt.Sprint and logs the result with the OpenFile level
2018-07-06 13:31:42 +00:00
func OpenFile() error {
return DefaultLogger.OpenFile()
}
2018-09-19 22:28:37 +00:00
// Close formats the given parts with fmt.Sprint and logs the result with the Close level
2018-07-06 13:31:42 +00:00
func Close() {
DefaultLogger.Close()
}
2018-09-19 22:28:37 +00:00
// Sub creates a Sublogger
func Sub(module string) Logger {
return DefaultLogger.Sub(module)
2018-07-06 13:31:42 +00:00
}
2018-09-19 22:28:37 +00:00
// Raw formats the given parts with fmt.Sprint and logs the result with the Raw level
2018-07-06 13:31:42 +00:00
func Raw(level Level, module, message string) {
DefaultLogger.Raw(level, module, message)
}
2018-09-19 22:28:37 +00:00
// Log formats the given parts with fmt.Sprint and logs the result with the given level
2018-07-06 13:31:42 +00:00
func Log(level Level, parts ...interface{}) {
DefaultLogger.DefaultSub.Log(level, parts...)
}
2018-09-19 22:28:37 +00:00
// Logln formats the given parts with fmt.Sprintln and logs the result with the given level
2018-07-06 13:31:42 +00:00
func Logln(level Level, parts ...interface{}) {
DefaultLogger.DefaultSub.Logln(level, parts...)
}
2018-09-19 22:28:37 +00:00
// Logf formats the given message and args with fmt.Sprintf and logs the result with the given level
2018-07-06 13:31:42 +00:00
func Logf(level Level, message string, args ...interface{}) {
DefaultLogger.DefaultSub.Logf(level, message, args...)
}
2018-09-19 22:28:37 +00:00
// Logfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the given level
func Logfln(level Level, message string, args ...interface{}) {
DefaultLogger.DefaultSub.Logfln(level, message, args...)
}
// Debug formats the given parts with fmt.Sprint and logs the result with the Debug level
2018-07-06 13:31:42 +00:00
func Debug(parts ...interface{}) {
DefaultLogger.DefaultSub.Debug(parts...)
}
2018-09-19 22:28:37 +00:00
// Debugln formats the given parts with fmt.Sprintln and logs the result with the Debug level
2018-07-06 13:31:42 +00:00
func Debugln(parts ...interface{}) {
DefaultLogger.DefaultSub.Debugln(parts...)
}
2018-09-19 22:28:37 +00:00
// Debugf formats the given message and args with fmt.Sprintf and logs the result with the Debug level
2018-07-06 13:31:42 +00:00
func Debugf(message string, args ...interface{}) {
DefaultLogger.DefaultSub.Debugf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Info formats the given parts with fmt.Sprint and logs the result with the Info level
2018-07-06 13:31:42 +00:00
func Info(parts ...interface{}) {
DefaultLogger.DefaultSub.Info(parts...)
}
2018-09-19 22:28:37 +00:00
// Infoln formats the given parts with fmt.Sprintln and logs the result with the Info level
2018-07-06 13:31:42 +00:00
func Infoln(parts ...interface{}) {
DefaultLogger.DefaultSub.Infoln(parts...)
}
2018-09-19 22:28:37 +00:00
// Infof formats the given message and args with fmt.Sprintf and logs the result with the Info level
2018-07-06 13:31:42 +00:00
func Infof(message string, args ...interface{}) {
DefaultLogger.DefaultSub.Infof(message, args...)
}
2018-09-19 22:28:37 +00:00
// Warn formats the given parts with fmt.Sprint and logs the result with the Warn level
2018-07-06 13:31:42 +00:00
func Warn(parts ...interface{}) {
DefaultLogger.DefaultSub.Warn(parts...)
}
2018-09-19 22:28:37 +00:00
// Warnln formats the given parts with fmt.Sprintln and logs the result with the Warn level
2018-07-06 13:31:42 +00:00
func Warnln(parts ...interface{}) {
DefaultLogger.DefaultSub.Warnln(parts...)
}
2018-09-19 22:28:37 +00:00
// Warnf formats the given message and args with fmt.Sprintf and logs the result with the Warn level
2018-07-06 13:31:42 +00:00
func Warnf(message string, args ...interface{}) {
DefaultLogger.DefaultSub.Warnf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Error formats the given parts with fmt.Sprint and logs the result with the Error level
2018-07-06 13:31:42 +00:00
func Error(parts ...interface{}) {
DefaultLogger.DefaultSub.Error(parts...)
}
2018-09-19 22:28:37 +00:00
// Errorln formats the given parts with fmt.Sprintln and logs the result with the Error level
2018-07-06 13:31:42 +00:00
func Errorln(parts ...interface{}) {
DefaultLogger.DefaultSub.Errorln(parts...)
}
2018-09-19 22:28:37 +00:00
// Errorf formats the given message and args with fmt.Sprintf and logs the result with the Error level
2018-07-06 13:31:42 +00:00
func Errorf(message string, args ...interface{}) {
DefaultLogger.DefaultSub.Errorf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Fatal formats the given parts with fmt.Sprint and logs the result with the Fatal level
2018-07-06 13:31:42 +00:00
func Fatal(parts ...interface{}) {
DefaultLogger.DefaultSub.Fatal(parts...)
}
2018-09-19 22:28:37 +00:00
// Fatalln formats the given parts with fmt.Sprintln and logs the result with the Fatal level
2018-07-06 13:31:42 +00:00
func Fatalln(parts ...interface{}) {
DefaultLogger.DefaultSub.Fatalln(parts...)
}
2018-09-19 22:28:37 +00:00
// Fatalf formats the given message and args with fmt.Sprintf and logs the result with the Fatal level
2018-07-06 13:31:42 +00:00
func Fatalf(message string, args ...interface{}) {
DefaultLogger.DefaultSub.Fatalf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Write formats the given parts with fmt.Sprint and logs the result with the Write level
func (log *BasicLogger) Write(p []byte) (n int, err error) {
2018-07-06 13:31:42 +00:00
return log.DefaultSub.Write(p)
}
2018-09-19 22:28:37 +00:00
// Log formats the given parts with fmt.Sprint and logs the result with the given level
func (log *BasicLogger) Log(level Level, parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Log(level, parts...)
}
2018-09-19 22:28:37 +00:00
// Logln formats the given parts with fmt.Sprintln and logs the result with the given level
func (log *BasicLogger) Logln(level Level, parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Logln(level, parts...)
}
2018-09-19 22:28:37 +00:00
// Logf formats the given message and args with fmt.Sprintf and logs the result with the given level
func (log *BasicLogger) Logf(level Level, message string, args ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Logf(level, message, args...)
}
2018-09-19 22:28:37 +00:00
// Logfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the given level
func (log *BasicLogger) Logfln(level Level, message string, args ...interface{}) {
log.DefaultSub.Logfln(level, message, args...)
}
// Debug formats the given parts with fmt.Sprint and logs the result with the Debug level
func (log *BasicLogger) Debug(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Debug(parts...)
}
2018-09-19 22:28:37 +00:00
// Debugln formats the given parts with fmt.Sprintln and logs the result with the Debug level
func (log *BasicLogger) Debugln(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Debugln(parts...)
}
2018-09-19 22:28:37 +00:00
// Debugf formats the given message and args with fmt.Sprintf and logs the result with the Debug level
func (log *BasicLogger) Debugf(message string, args ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Debugf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Debugfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Debug level
func (log *BasicLogger) Debugfln(message string, args ...interface{}) {
log.DefaultSub.Debugfln(message, args...)
}
// Info formats the given parts with fmt.Sprint and logs the result with the Info level
func (log *BasicLogger) Info(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Info(parts...)
}
2018-09-19 22:28:37 +00:00
// Infoln formats the given parts with fmt.Sprintln and logs the result with the Info level
func (log *BasicLogger) Infoln(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Infoln(parts...)
}
2018-09-19 22:28:37 +00:00
// Infofln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Info level
func (log *BasicLogger) Infofln(message string, args ...interface{}) {
log.DefaultSub.Infofln(message, args...)
}
// Infof formats the given message and args with fmt.Sprintf and logs the result with the Info level
func (log *BasicLogger) Infof(message string, args ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Infof(message, args...)
}
2018-09-19 22:28:37 +00:00
// Warn formats the given parts with fmt.Sprint and logs the result with the Warn level
func (log *BasicLogger) Warn(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Warn(parts...)
}
2018-09-19 22:28:37 +00:00
// Warnln formats the given parts with fmt.Sprintln and logs the result with the Warn level
func (log *BasicLogger) Warnln(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Warnln(parts...)
}
2018-09-19 22:28:37 +00:00
// Warnfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Warn level
func (log *BasicLogger) Warnfln(message string, args ...interface{}) {
log.DefaultSub.Warnfln(message, args...)
}
// Warnf formats the given message and args with fmt.Sprintf and logs the result with the Warn level
func (log *BasicLogger) Warnf(message string, args ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Warnf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Error formats the given parts with fmt.Sprint and logs the result with the Error level
func (log *BasicLogger) Error(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Error(parts...)
}
2018-09-19 22:28:37 +00:00
// Errorln formats the given parts with fmt.Sprintln and logs the result with the Error level
func (log *BasicLogger) Errorln(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Errorln(parts...)
}
2018-09-19 22:28:37 +00:00
// Errorf formats the given message and args with fmt.Sprintf and logs the result with the Error level
func (log *BasicLogger) Errorf(message string, args ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Errorf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Errorfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Error level
func (log *BasicLogger) Errorfln(message string, args ...interface{}) {
log.DefaultSub.Errorfln(message, args...)
}
// Fatal formats the given parts with fmt.Sprint and logs the result with the Fatal level
func (log *BasicLogger) Fatal(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Fatal(parts...)
}
2018-09-19 22:28:37 +00:00
// Fatalln formats the given parts with fmt.Sprintln and logs the result with the Fatal level
func (log *BasicLogger) Fatalln(parts ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Fatalln(parts...)
}
2018-09-19 22:28:37 +00:00
// Fatalf formats the given message and args with fmt.Sprintf and logs the result with the Fatal level
func (log *BasicLogger) Fatalf(message string, args ...interface{}) {
2018-07-06 13:31:42 +00:00
log.DefaultSub.Fatalf(message, args...)
}
2018-09-19 22:28:37 +00:00
// Fatalfln formats the given message and args with fmt.Sprintf, appends a newline and logs the result with the Fatal level
func (log *BasicLogger) Fatalfln(message string, args ...interface{}) {
log.DefaultSub.Fatalfln(message, args...)
}