Simple Golang package for common logging requirements
Find a file
Simon Cornet adcd5319f8 Merge branch 'renovate_goreleaser-goreleaser-action-6.x' into 'main'
chore(package): update goreleaser/goreleaser-action action to v6

See merge request go/logger!1
2025-04-03 16:08:18 +00:00
.github Merge branch 'renovate_goreleaser-goreleaser-action-6.x' into 'main' 2025-04-03 16:08:18 +00:00
.gitignore feat: initial commit 2025-03-06 11:26:17 +01:00
.gitlab-ci.yml feat(ci): release using goreleaser 2025-04-03 17:27:22 +02:00
.goreleaser.yaml ci: dont exclude any commit from changelog 2025-04-03 18:06:12 +02:00
debug.go feat: rename package to logger 2025-03-06 11:58:51 +01:00
LICENSE feat: initial commit 2025-03-06 11:25:38 +01:00
logging.go feat: rename package to logger 2025-03-06 11:58:51 +01:00
prefix.go feat: rename package to logger 2025-03-06 11:58:51 +01:00
readme.md docs: improved readme 2025-03-06 12:30:04 +01:00
renovate.json feat: initial commit 2025-03-06 11:25:38 +01:00

Logger

This simple Golang package can be used for common logging functionality. Only when debug is on, non fatal errors will be shown.

Install

go get -u github.com/scornet256/go-logger

Basic usage

logger.Print("Simple log message withouth error", nil)
logger.Fatal("Fatal log message with error and exits the program", err)

Will output like this:

2025/12/01 11:17:35 MyApp | LOG: Simple log message withouth error
2025/12/01 11:17:35 MyApp | FATAL: Fatal log message with error
2025/12/01 11:17:35 MyApp | ERROR: <insert value of err> 

Options

logger.SetAppName("todo-app")     # optional; default "MyApp"
logger.SetDebug(true)             # optional; default false

Return functions

logger.GetAppName()  # will return the current used app name as a string.
logger.GetDebug()    # will return the current debug setting as a bool.