A simple, yet effective and clean logger
Find a file
tkarrass 9803527e65 doc: Add partial documentation.
refactor: Move Envelope interface.
fix: Deadlock when logging traces.
fix: Suppress hook execution, when logging traces.
feat: Formatter initialization and configuration.
feat: Exit hook on FATAL logs.
chore: Prepare tokenizer for log configuration parsing.
fix: Early formatter/logger init.
feat: Supply version and build information.
2025-11-21 15:23:28 +01:00
example feat: implement formatter support; feat: add wrapper for grpclog 2025-11-19 03:37:21 +01:00
formatter/json doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
lex doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
.gitignore repo init 2024-01-09 12:54:30 +01:00
doc.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
envelope.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
formatter.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
formatter_plain.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
go.mod chore: update deps 2025-11-19 08:43:25 +01:00
go.sum chore: update deps 2025-11-19 08:43:25 +01:00
grpc.go feat: implement formatter support; feat: add wrapper for grpclog 2025-11-19 03:37:21 +01:00
level.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
logger.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
README.md doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
tag.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00
version.go doc: Add partial documentation. 2025-11-21 15:23:28 +01:00

log

Package log provides an easy to use, yet highly configurable Logger.

Usage

In its simplest form, a log message can be created by just:

import "udico.de/util/log"
log.INFO.Msg("Hello log!")

This will use the default Logger without further configuration and produce something like this to stdout:

20251121-113125.038747 INFO: Hello log!

If stdout targets an interactive terminal, the output will be colored by the default formatter. More on Formatters below.

Customizing a Logger

Of course, you can customize a Logger

log.DefaultLogger.SetLevel(log.TRACE)
// .SetFormatter(...)
// .SetAutotrace(...)
package mypackage

import "udico.de/util/log"

var logger = log.Logger("mylog").SetLevel(log.DEBUG)
Autotrace

Log levels

udilog provides the following log levels:

Level Name (Short) Description
0 SILENT (SLT) No log at all. not even panics. We just don't care about the end of the world.
1 PANIC (PNC) Events which cannot be handled gracefully. Program execution will terminate.
2 FATAL (FTL) Indicates a situation which requires user interaction to resolve.
3 ERROR (ERR) Error conditions which may result in malfunction.
4 WARN (WRN) Signifies potential issues that may lead to errors or unexpected behavior in the future if not addressed.
5 NOTICE (NOT) Notice logs are normal but significant information.
6 INFO (INF) Indicates normal, informational messages.
7 DEBUG (DBG) Is intended for logging detailed information for debugging purposes.
8 TRACE (TRC) Is the most detailed level of log output. Might spam your logs.

Note: logging a PANIC will also issue a panic and thereby terminate the program.

Configuration

stub

Formatters

stub

Targets

stub

gRPC

You can also use a Logger for gRPC logging.