Simple Golang package for common logging requirements
Find a file
Simon Cornet d7a0fb654d Merge branch 'renovate_actions-setup-go-6.x' into 'main'
chore(package): update actions/setup-go action to v6

See merge request go/logger!3
2025-12-09 21:32:23 +01:00
.github chore(package): update actions/setup-go action to v6 2025-11-16 15:00:56 +00:00
.gitignore feat: initial commit 2025-03-06 11:26:17 +01:00
.gitlab-ci.yml chore(package): update goreleaser/goreleaser docker tag to v2.12.3 2025-09-25 04:48:31 +00:00
.goreleaser.yaml ci(release): add release name 2025-04-04 11:41:34 +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.