Skip to content

Latest commit

 

History

History
181 lines (123 loc) · 4.32 KB

log.md

File metadata and controls

181 lines (123 loc) · 4.32 KB

log

import "github.com/image357/password/log"

Index

Constants

const LevelDebug = slog.LevelDebug

const LevelError = slog.LevelError

const LevelInfo = slog.LevelInfo

const LevelWarn = slog.LevelWarn

Variables

CustomLoggerLevel stores the current log level. Set it with Level()

var CustomLoggerLevel = &slog.LevelVar{}

Logger is the global log instance. Overwrite it with any slog.New() compatible logger to use your custom logger.

var Logger = slog.Default()

LoggerFileMode controls the file permission set by the custom file loggers of this package.

var LoggerFileMode os.FileMode = 0600

func Debug

func Debug(msg string, args ...any)

Debug will call [slog.Logger.Debug] on the global logger.

func Error

func Error(msg string, args ...any)

Error will call [slog.Logger.Error] on the global logger.

func Info

func Info(msg string, args ...any)

Info will call [slog.Logger.Info] on the global logger.

func Level

func Level(level slog.Level) (oldLevel slog.Level)

Level sets the global log level and returns the previous value.

func SetDefault()

SetDefault will set the global Logger variable to slog.Default()

func SetFileJSON(filePath string) error

SetFileJSON will set a custom file logger with JSON format.

func SetFileText(filePath string) error

SetFileText will set a custom file logger with text format.

func SetMultiJSON(filePath string) error

SetMultiJSON will set a custom logger with JSON format, that will write into a file and os.Stderr.

func SetMultiText(filePath string) error

SetMultiText will set a custom logger with text format, that will write into a file and os.Stderr.

func SetStderrJSON()

SetStderrJSON will set a custom os.Stderr logger with JSON format.

func SetStderrText()

SetStderrText will set a custom os.Stderr logger with text format.

func Warn

func Warn(msg string, args ...any)

Warn will call [slog.Logger.Warn] on the global logger.

Generated by gomarkdoc