Categorygithub.com/chmike/clog
modulepackage
0.0.8
Repository: https://github.com/chmike/clog.git
Documentation: pkg.go.dev

# README

Simple logging system

This simple logging system provides logging levels, file storage and file rotation. It also provides a command to display colorized logs.

By default, the logging output is printed to stdout.

Installation

Since clog provides a command to display logs with colors, the clog package must be installed with the command line instruction

$ go install github.com/chmike/clog/cmd/...@latest

This installs the package and the commands clogClr and testClog.

Usage

The command testClog outputs various logging messages to stdout. The first character of a log line specifies the log level.

  • F : Fatal error message causing the program to stop.
  • E : Error message requiring human intervention to fix the problem.
  • W : Warning message reporting an error that is automatically fixed by the program.
  • I : Information message is for key milestones achievements.
  • _ : (white space) It's just a normal information message.
  • . : Debug message of level 0
    • : Debug message of level 1
  • = : Debug message of level 2

The command clogClr accept as optional argument a log file to read, otherwise it will read logging messages from stdin. It will then colorize lines according to the logging level. Executing the command testClog | clogClr will demonstrate its effect.

A handy usage pattern when logging messages are written to files is to use the command tail -F log_latest | clogClr. Where log_latest is the link file to the latest log file created by the clog package.

# Packages

No description provided by the author

# Functions

Debug logs a debug message for minimum verbosity.
Debug1 logs a debug message for intermediate verbosity.
Debug1f logs a debug message for intermediate verbosity.
Debug1ln logs a debug message for intermediate verbosity.
Debug2 logs a debug message fon maximum verbosity.
Debug2f logs a debug message fon maximum verbosity.
Debug2ln logs a debug message fon maximum verbosity.
Debugf logs a formatted debug message for minimum verbosity.
Debugln logs a debug message for minimum verbosity.
Error logs an error requiring an intervention.
Errorf logs a formatted error requiring an intervention.
Errorln logs an error requiring an intervention.
Fatal logs a fatal error and exit the program with a status 1.
Fatalf logs a formatted error and exits the program with a status 1.
Fatalln logs a fatal error and exit the program with a status 1.
Info logs a major progress notification.
Infof logs a formatted major progress notification.
Infoln logs a major progress notification.
Level returns the main log level.
LevelFromString returns the level corresponding to s, or PrintLevel by default.
New return a logger with a distinct tag and level.
Print logs a normal progress notification.
Printf logs a formatted normal progress notification.
Println logs a normal progress notification.
SetFileOutput sets the output to files with the given prefix and maximum byte length.
SetLevel sets the main level.
Warning logs a self corrected error.
Warningf logs a formatted self corrected error.
Warningln logs a self corrected error.

# Constants

Debug message with intermediate verbosity.
Debug message with maximum verbosity.
Debug message with minimum verbosity.
Error requiring intervention.
Terminate program.
Major progress notification.
Progress notification.
Self corrected error.

# Structs

Clog manages logging with a specific level and tag name.
Options are the logging options.

# Type aliases

No description provided by the author