logHandler

package
v1.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 32

README

logHandler

logHandler centralises application logging and log file rotation.

It exposes a set of preconfigured *log.Logger instances (Info, Warning, Error, Timing, Audit, etc.) which write to stdout/stderr and to rotating log files (via lumberjack).

How it works

  • Initialises automatically via init() when the package is imported.
  • Log file location is derived from the application paths and the configured application name.
  • Most log categories can be enabled/disabled via commonConfig.
  • Uses ANSI colour prefixes on non-Windows platforms.

Common loggers

A few of the exported loggers:

  • logHandler.InfoLogger
  • logHandler.WarningLogger
  • logHandler.ErrorLogger
  • logHandler.PanicLogger
  • logHandler.TimingLogger
  • logHandler.AuditLogger
  • logHandler.DatabaseLogger
  • logHandler.CacheLogger

(There are more categories in logHandler.go.)

Usage

package main

import (
    "github.com/mt1976/frantic-core/logHandler"
)

func main() {
    logHandler.Info.Println("hello")
    logHandler.Warning.Println("something to look at")
    logHandler.Error.Println("something failed")

    logHandler.InfoBanner("startup", "init", "application starting")
    logHandler.Break()
}

Notes

  • Because initialisation happens in init(), importing this package will create/open the log writers immediately.
  • Rotation settings (max size, backups, age, compression) are taken from commonConfig.

Documentation

Overview

Package logHandler centralizes application logging facilities and helpers.

Index

Constants

This section is empty.

Variables

View Source
var (
	Warning        *log.Logger
	Info           *log.Logger
	Error          *log.Logger
	Panic          *log.Logger
	Timing         *log.Logger
	Event          *log.Logger
	Service        *log.Logger
	Trace          *log.Logger
	Audit          *log.Logger
	Translation    *log.Logger
	Security       *log.Logger
	Database       *log.Logger
	Api            *log.Logger
	Import         *log.Logger
	Export         *log.Logger
	Communications *log.Logger
	Lock           *log.Logger
	Unlock         *log.Logger
	SkipLock       *log.Logger
	Cache          *log.Logger
	Web            *log.Logger
)
View Source
var (
	Reset   string
	Red     string
	Green   string
	Yellow  string
	Blue    string
	Magenta string
	Cyan    string
	Gray    string
	White   string
)

Functions

func Banner(logCategory, logActivity, logMessage string)

func Break added in v1.2.41

func Break()

func ServiceBanner

func ServiceBanner(logCategory, logActivity, logMessage string)

ServiceBanner - log a banner message to the service log Deprecated: No longer to be used

func TestIt

func TestIt()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL