slog

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 8

Documentation

Overview

Package slog provides slog logging.

Index

Constants

View Source
const (
	LevelTrace = Level(-8)
	LevelDebug = Level(slog.LevelDebug)
	LevelInfo  = Level(slog.LevelInfo)
	LevelWarn  = Level(slog.LevelWarn)
	LevelError = Level(slog.LevelError)
	LevelFatal = Level(12)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int

type Log

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

Log is struct that provides log related methods.

func (*Log) Debug

func (this *Log) Debug(message string, arguments ...any)

Debug means recording debug level logs.

ex) testLog.Debug("message-02", "key-01", "value-02", "key-02", 2)

func (*Log) Error

func (this *Log) Error(message string, arguments ...any)

Error means recording error level logs.

ex) testLog.Error("message-05", "key-01", "value-05", "key-02", 5)

func (*Log) Fatal

func (this *Log) Fatal(message string, arguments ...any)

Fatal means recording fatal level logs.

ex) testLog.Fatal("message-06", "key-01", "value-06", "key-02", 6)

func (*Log) Flush

func (this *Log) Flush()

Flush waits to record the logs accumulated up to the time it was called.

ex) testLog.Flush()

func (*Log) GetLevel

func (this *Log) GetLevel() Level

GetLevel gets the level.

ex) level := testLog.GetLevel()

func (*Log) Info

func (this *Log) Info(message string, arguments ...any)

Info means recording info level logs.

ex) testLog.Info("message-03", "key-01", "value-03", "key-02", 3)

func (*Log) SetLevel

func (this *Log) SetLevel(level Level)

SetLevel sets the level.

ex) testLog.SetLevel(log.LevelInfo)

func (*Log) SetOutputToFile

func (this *Log) SetOutputToFile(fileName, fileExtensionName string, addDate bool)

SetOutputToFile sets the output to file.

ex) testLog.SetOutputToFile(fileName, fileExtensionName, true)

func (*Log) SetOutputToStderr

func (this *Log) SetOutputToStderr()

SetOutputToStderr sets the output to standard error.

ex) testLog.SetOutputToStderr()

func (*Log) SetOutputToStdout

func (this *Log) SetOutputToStdout()

SetOutputToStdout sets the output to standard output.

ex) testLog.SetOutputToStdout()

func (*Log) SetWithCallerInfo

func (this *Log) SetWithCallerInfo(withCallerInfo bool)

SetWithCallerInfo also records caller information.

ex) testLog.SetWithCallerInfo(true)

func (*Log) Trace

func (this *Log) Trace(message string, arguments ...any)

Trace means recording trace level logs.

ex) testLog.Trace("message-01", "key-01", "value-01", "key-02", 1)

func (*Log) Warn

func (this *Log) Warn(message string, arguments ...any)

Warn means recording warn level logs.

ex) testLog.Warn("message-04", "key-01", "value-04", "key-02", 4)

Jump to

Keyboard shortcuts

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