sloge

package module
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 11 Imported by: 1

README

Sloge Package

Introduction

This package is an enhancement for 'log/slog' and provides richer functionality for 'log/slog'.

Usage

import "github.com/origadmin/toolkits/sloge"

func main(){
    l := sloge.New()
    l.Info("hello world")
}

Documentation

Overview

Package sloge implements the functions, types, and interfaces for the module.

Package sloge implements the functions, types, and interfaces for the module.

Package sloge implements the functions, types, and interfaces for the module.

Package sloge implements the functions, types, and interfaces for the module.

Index

Constants

View Source
const (
	KindAny       = slog.KindAny
	KindBool      = slog.KindBool
	KindDuration  = slog.KindDuration
	KindFloat64   = slog.KindFloat64
	KindGroup     = slog.KindGroup
	KindInt64     = slog.KindInt64
	KindLogValuer = slog.KindLogValuer
	KindString    = slog.KindString
	KindTime      = slog.KindTime
	KindUint64    = slog.KindUint64
	LevelDebug    = slog.LevelDebug
	LevelError    = slog.LevelError
	LevelInfo     = slog.LevelInfo
	LevelKey      = slog.LevelKey
	LevelWarn     = slog.LevelWarn
	MessageKey    = slog.MessageKey
	SourceKey     = slog.SourceKey
	TimeKey       = slog.TimeKey
)

slog is a wrapper around slog

View Source
const (
	Black        = devslog.Black
	Blue         = devslog.Blue
	Cyan         = devslog.Cyan
	Green        = devslog.Green
	Magenta      = devslog.Magenta
	Red          = devslog.Red
	UnknownColor = devslog.UnknownColor
	White        = devslog.White
	Yellow       = devslog.Yellow
)

devslog is a wrapper around devslog

View Source
const (
	// DefaultTimeLayout the default time layout;
	DefaultTimeLayout = time.DateTime
)
View Source
const (
	LevelFatal = 12
)

Variables

View Source
var (
	Any               = slog.Any
	AnyValue          = slog.AnyValue
	Bool              = slog.Bool
	BoolValue         = slog.BoolValue
	Debug             = slog.Debug
	DebugContext      = slog.DebugContext
	Default           = slog.Default
	Duration          = slog.Duration
	DurationValue     = slog.DurationValue
	Error             = slog.Error
	ErrorContext      = slog.ErrorContext
	Float64           = slog.Float64
	Float64Value      = slog.Float64Value
	Group             = slog.Group
	GroupValue        = slog.GroupValue
	Info              = slog.Info
	InfoContext       = slog.InfoContext
	Int               = slog.Int
	Int64             = slog.Int64
	Int64Value        = slog.Int64Value
	IntValue          = slog.IntValue
	Log               = slog.Log
	LogAttrs          = slog.LogAttrs
	NewJSONHandler    = slog.NewJSONHandler
	NewLogLogger      = slog.NewLogLogger
	NewRecord         = slog.NewRecord
	NewTextHandler    = slog.NewTextHandler
	SetDefault        = slog.SetDefault
	SetLogLoggerLevel = slog.SetLogLoggerLevel
	String            = slog.String
	StringValue       = slog.StringValue
	Time              = slog.Time
	TimeValue         = slog.TimeValue
	Uint64            = slog.Uint64
	Uint64Value       = slog.Uint64Value
	Warn              = slog.Warn
	WarnContext       = slog.WarnContext
	With              = slog.With
)
View Source
var (
	Err            = tint.Err
	NewTintHandler = tint.NewHandler
)

tint is a wrapper around tint

View Source
var (
	// NewDevSlogHandler is a wrapper around devslog.NewHandler
	NewDevSlogHandler = devslog.NewHandler
)

Functions

This section is empty.

Types

type Attr

type Attr = slog.Attr

slog is a wrapper around slog

type Color

type Color = devslog.Color

devslog is a wrapper around devslog

type DevConfig

type DevConfig = devslog.Options

devslog is a wrapper around devslog

type Format

type Format int
const (
	// FormatJSON json format
	FormatJSON Format = iota
	// FormatText text format
	FormatText
	// FormatTint tint format
	FormatTint
	// FormatDev dev format
	FormatDev
)

func (Format) String

func (i Format) String() string

type Handler

type Handler = slog.Handler

slog is a wrapper around slog

type HandlerOptions

type HandlerOptions = slog.HandlerOptions

slog is a wrapper around slog

type JSONHandler

type JSONHandler = slog.JSONHandler

slog is a wrapper around slog

type Kind

type Kind = slog.Kind

slog is a wrapper around slog

type Level

type Level = slog.Level

slog is a wrapper around slog

type LevelVar

type LevelVar = slog.LevelVar

slog is a wrapper around slog

type Leveler

type Leveler = slog.Leveler

slog is a wrapper around slog

type LogValuer

type LogValuer = slog.LogValuer

slog is a wrapper around slog

type Logger

type Logger = slog.Logger

slog is a wrapper around slog

func New

func New(ss ...Setting) *Logger

New create a new slog.Logger

func NewDebug added in v0.0.7

func NewDebug(ss ...Setting) *Logger

NewDebug create a new slog.Logger with debug level

type LumberjackLogger

type LumberjackLogger = lumberjack.Logger

LumberjackLogger is a wrapper around lumberjack.Logger

type Option

type Option struct {
	Output           string
	Format           Format
	TimeLayout       string
	Console          bool
	Level            Leveler
	ReplaceAttr      func(groups []string, attr Attr) Attr
	AddSource        bool
	LumberjackConfig *LumberjackLogger
	DevConfig        *DevConfig
	NoColor          bool
	Default          bool
}

Option custom setup config

type Record

type Record = slog.Record

slog is a wrapper around slog

type Setting

type Setting = func(*Option)

func WithAddSource

func WithAddSource() Setting

WithAddSource add source info to log

func WithConsole

func WithConsole(set bool) Setting

WithConsole set the log to console or /dev/null

func WithConsoleOnly added in v0.0.7

func WithConsoleOnly() Setting

WithConsoleOnly set the log to console only

func WithDefault

func WithDefault(set bool) Setting

WithDefault use output as slog.Default()

func WithDevConfig

func WithDevConfig(config *DevConfig) Setting

WithDevConfig set dev config

func WithFile

func WithFile(file string) Setting

WithFile write log to some File

func WithFormat

func WithFormat(format Format) Setting

WithFormat custom format

func WithLevel

func WithLevel(level Leveler) Setting

WithLevel custom log level

func WithLumberjack

func WithLumberjack(config *LumberjackLogger) Setting

WithLumberjack write log to some File with rotation

func WithNoColor

func WithNoColor() Setting

WithNoColor disable color

func WithReplaceAttr

func WithReplaceAttr(replaceAttr func(groups []string, attr Attr) Attr) Setting

WithReplaceAttr custom replaceAttr

func WithTimeLayout

func WithTimeLayout(timeLayout string) Setting

WithTimeLayout custom time format

type Source

type Source = slog.Source

slog is a wrapper around slog

type TextHandler

type TextHandler = slog.TextHandler

slog is a wrapper around slog

type TintOptions

type TintOptions = tint.Options

TintOptions is a wrapper around tint.Options

type Value

type Value = slog.Value

slog is a wrapper around slog

Jump to

Keyboard shortcuts

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