Skip to content

itametis/bash-lib-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bash lib logger

This library is a single Bash file helping you to write logs with color in yours scripts.

Usage

To load and use this lib, just respect the following order.

1) Define the LOG_LEVEL variable to the existing log levels.

The existing log levels are :

  • $LOG_LEVEL_TRACE
  • $LOG_LEVEL_DEBUG
  • $LOG_LEVEL_INFOS
  • $LOG_LEVEL_WARNING
  • $LOG_LEVEL_ERROR

For instance : export LOG_LEVEL="$LOG_LEVEL_DEBUG"

2) Define a LOG_OUTPUT variable.

For instance : export LOG_OUTPUT="/var/log/my-file.log"

or export LOG_OUTPUT="" to redirect all logs in the current output (generally the console).

3) Source this file then use it.

For instance :

. ./lib-logger.sh
LOGGER_logTrace "This log is written at TRACE level"
LOGGER_logDebug "This log is written at DEBUG level"
LOGGER_logInfo "This log is written at INFO level"
LOGGER_logWarning "This log is written at WARNING level"
LOGGER_logError "This log is written at ERROR level"

The related console output: screenshot

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages