cclogger

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 4 Imported by: 10

README

ccLogger interface

The ccLogger component is an approach to unify logging over the various components of ClusterCockpit. It is suitable to work with systemd's journaling.

Documentation

Overview

Package cclogger implements a simple log wrapper for the standard log package

cclogger provides a simple way of logging with different levels. Time/Date are not logged because systemd adds them (default, can be changed by setting logdate to true. Additionally log output can be set to a file. Default output is stderr. Uses these prefixes: https://www.freedesktop.org/software/systemd/man/sd-daemon.html

Index

Constants

This section is empty.

Variables

View Source
var (
	DebugWriter io.Writer = os.Stderr
	InfoWriter  io.Writer = os.Stderr
	WarnWriter  io.Writer = os.Stderr
	ErrWriter   io.Writer = os.Stderr
	CritWriter  io.Writer = os.Stderr
)
View Source
var (
	DebugPrefix string = "<7>[DEBUG]    "
	InfoPrefix  string = "<6>[INFO]     "
	WarnPrefix  string = "<4>[WARNING]  "
	ErrPrefix   string = "<3>[ERROR]    "
	CritPrefix  string = "<2>[CRITICAL] "
)

Functions

func Abort

func Abort(v ...any)

Abort logs to STDOUT without string formatting; application exits with error code 1. Used for terminating with message after to be expected errors, e.g. wrong arguments or during init().

func Abortf

func Abortf(format string, v ...any)

Abortf logs to STDOUT with string formatting; application exits with error code 1. Used for terminating with message after to be expected errors, e.g. wrong arguments or during init().

func ComponentDebug

func ComponentDebug(component string, v ...any)

func ComponentError

func ComponentError(component string, v ...any)

func ComponentInfo added in v0.2.0

func ComponentInfo(component string, v ...any)

func ComponentPrint

func ComponentPrint(component string, v ...any)

func ComponentWarn added in v0.2.0

func ComponentWarn(component string, v ...any)

func Debug

func Debug(v ...any)

Debug logs to DEBUG writer without string formatting; application continues. Used for logging additional information, primarily for development.

func Debugf

func Debugf(format string, v ...any)

Debugf logs to DEBUG writer with string formatting; application continues. Used for logging additional information, primarily for development.

func Error

func Error(v ...any)

Error logs to ERROR writer without string formatting; application continues. Used for logging errors, but code still can return default(s) or nil.

func Errorf

func Errorf(format string, v ...any)

Errorf logs to ERROR writer with string formatting; application continues. Used for logging errors, but code still can return default(s) or nil.

func Exit

func Exit(v ...any)

Exit logs to STDOUT without string formatting; application exits with error code 0. Used for exiting succesfully with message after expected outcome, e.g. successful single-call application runs.

func Exitf

func Exitf(format string, v ...any)

Exitf logs to STDOUT with string formatting; application exits with error code 0. Used for exiting succesfully with message after expected outcome, e.g. successful single-call application runs.

func Fatal

func Fatal(v ...any)

Fatal writes to CRITICAL writer without string formatting; application exits with error code 1. Used for terminating on unexpected errors with date and code location.

func Fatalf

func Fatalf(format string, v ...any)

Fatalf logs to CRITICAL writer with string formatting; application exits with error code 1. Used for terminating on unexpected errors with date and code location.

func Info

func Info(v ...any)

Info logs to INFO writer without string formatting; application continues. Used for logging additional information, e.g. notable returns or common fail-cases.

func Infof

func Infof(format string, v ...any)

Infof log to INFO writer with string formatting; application continues. Used for logging additional information, e.g. notable returns or common fail-cases.

func Init

func Init(lvl string, logdate bool)

Init initializes cclogger. lvl indicates the loglevel with such values as "debug", "info", "warn", "err", "fatal", "crit". If logdate is set to true a date and time is added to the log output.

func Loglevel

func Loglevel() string

Loglevel returns the current loglevel

func Panic

func Panic(v ...any)

Panic logs to PANIC function without string formatting; application exits with panic. Used for terminating on unexpected errors with stacktrace.

func Panicf

func Panicf(format string, v ...any)

Panicf logs to PANIC function with string formatting; application exits with panic. Used for terminating on unexpected errors with stacktrace.

func Print

func Print(v ...any)

Print logs to STDOUT without string formatting; application continues. Used for special cases not requiring log information like date or location.

func Printf

func Printf(format string, v ...any)

Printf logs to STDOUT with string formatting; application continues. Used for special cases not requiring log information like date or location.

func SetOutputFile added in v0.2.0

func SetOutputFile(lvl string, logfile string)

SetOutputFile sets the output of selected loglevels to a file indicated by the logfile function argument. All loggers lower than lvl are set to the output file. Example: If lvl is warn, the warn, info, and debug loggers will write to logfile.

func Warn

func Warn(v ...any)

Warn logs to WARNING writer without string formatting; application continues. Used for logging important information, e.g. uncommon edge-cases or administration related information.

func Warnf

func Warnf(format string, v ...any)

Warnf logs to WARNING writer with string formatting; application continues. Used for logging important information, e.g. uncommon edge-cases or administration related information.

Types

This section is empty.

Jump to

Keyboard shortcuts

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