8000 GitHub - cdfmlr/slogconfig: configurations for "log/slog"
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

cdfmlr/slogconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

slogconfig

Go Reference

Package slogconfig provides common configuration items for "log/slog".

install

go get github.com/cdfmlr/slogconfig

usage

Works with github.com/cdfmlr/configer:

package main

import (
	"github.com/cdfmlr/configer"
	"github.com/cdfmlr/slogconfig"
)

type appConfig struct {
	SlogConfig slogconfig.SlogConfig
	// other fields...
}

func main() {
	var cfg appConfig
	configer.New(&cfg, configer.TOML).ReadFromFile("config.toml")

	cfg.SlogConfig.SetSlogDefault()
	// now slog.Default() is set to a new Logger based on the config.
}

example config.toml:

[Log]
Level = "info"    # one of "debug", "info" (default), "warn" or "error"
Format = "json"   # one of "text" or "json" (default)
Output = "stdout" # one of "stderr", "stdout" (default) or "path/to/customFile.log"

About

configurations for "log/slog"

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages

0