website/pkg/log/log.go
Noah dd1e6c2918 Initial commit
* Initial codebase (lot of work!)
* Uses vanilla Go net/http and implements by hand: session cookies
  backed by Redis; log in/out; CSRF protection; email verification flow;
  initial database models (User table)
2022-08-09 22:32:19 -07:00

56 lines
951 B
Go

// Package log centralizes logging for the app.
package log
import (
"os"
golog "git.kirsle.net/go/log"
)
var log golog.Logger
func init() {
log = *golog.GetLogger("main")
log.Configure(&golog.Config{
Colors: golog.ExtendedColor,
Theme: golog.DarkTheme,
})
log.Config.Level = golog.DebugLevel
}
// SetDebug toggles debug level logging.
func SetDebug(v bool) {
if v {
log.Config.Level = golog.DebugLevel
} else {
log.Config.Level = golog.InfoLevel
}
}
// Info log.
func Info(message string, v ...interface{}) {
log.Info(message, v...)
}
// Debug log.
func Debug(message string, v ...interface{}) {
log.Debug(message, v...)
}
// Warn log.
func Warn(message string, v ...interface{}) {
log.Warn(message, v...)
}
// Error log.
func Error(message string, v ...interface{}) {
log.Error(message, v...)
}
// Fatal logs an error and exits.
func Fatal(message string, v ...interface{}) {
log.Error(message, v...)
os.Exit(1)
}