NetLife Guru

Open source Go packages for fast, maintainable web systems. Built with a documentation-first approach.

Product
OverviewGolang packagesNews
Documentation
DocumentationGo LoggerGo RouterGo DB Form
Company
OverviewContactNewsGitHub
Community / Support
Supportinfo@netlife.guru
© 2026 NetLife Guru. All rights reserved.
GitHubinfo@netlife.guru
NetLife GuruNetLife GuruNetLife Guru
NetLife GuruNetLife GuruNetLife Guru
OverviewDocumentationNewsSupportContact

Golang packages

Logger Introduction
Colorized Terminal OutputSeparate Log LevelsCustom Notice Level
LoggerTerminal Output

Separate Log Levels

The logger supports independent log levels for file output and terminal output.

This allows applications to store stable production logs in files while showing more detailed information in the console during development or debugging sessions.

Configuration is controlled through:

  • MinLevel
  • ConsoleMinLevel

Example configuration:

package main

import (
	"log/slog"

	"github.com/netlifeguru/logger"
)

func main() {
	closer, err := logger.Init(logger.Config{
		TerminalOutput:  true,
		MinLevel:        slog.LevelInfo,
		ConsoleMinLevel: slog.LevelDebug,
	})

	if err != nil {
		slog.Error(err.Error())
	}

	defer closer.Close()

	slog.Debug("debug message")
	slog.Info("application started")
	slog.Warn("warning message")
}

In this configuration:

  • log files store:
    • INFO
    • WARN
    • ERROR
  • terminal output displays:
    • DEBUG
    • INFO
    • WARN
    • ERROR

Example terminal output:

2026-05-11 11:42:18 DBG debug message
2026-05-11 11:42:18 INF application started
2026-05-11 11:42:18 WRN warning message

Example file output:

{
  "time": "2026-05-11T11:42:18.102391+02:00",
  "level": "INFO",
  "msg": "application started"
}

If ConsoleMinLevel is not specified, terminal output automatically uses the same level as MinLevel.

This separation is especially useful for:

  • local debugging
  • development environments
  • production observability
  • reducing noise in persisted logs

Colorized Terminal Output

Previous Page

Custom Notice Level

The logger includes a custom `LevelNotice` log level designed for important operational messages that should remain highly visible in terminal output.