Coder Social home page Coder Social logo

bash-logger's Introduction

Bash Logger

Fork of Bash Logger designed to incorperate PSR-3 compliance.

Contributors

  • Dean Rather
  • Fred Palmer

Using Bash Logger

source the bash-logger.sh script at the beginning of any Bash program.

    #!/bin/bash
    source /path/to/bash-logger.sh

    INFO "This is a test info log"

Function names are in CAPS as not to conflict with the info function and alert aliases.

An Overview of Bash Logger

Colorized Output

Colour Screenshot

Logging Levels

Bash Logger supports the logging levels described by RFC 5424.

  • DEBUG Detailed debug information.

  • INFO Interesting events. Examples: User logs in, SQL logs.

  • NOTICE Normal but significant events.

  • WARNING Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

  • ERROR Runtime errors that do not require immediate action but should typically be logged and monitored.

  • CRITICAL Critical conditions. Example: Application component unavailable, unexpected exception.

  • ALERT Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

  • EMERGENCY Emergency: system is unusable.

Handlers

By default:

  • Logs are displayed in colour
  • Logs are written to ~/bash-logger.log
  • error level logs and above exit with an error code

The colours, logfile, default behavior, and log-level behavior can all be overwritten, see examples.sh for examples.

bash-logger's People

Contributors

deanrather avatar domdorn avatar fredpalmer avatar

Watchers

 avatar  avatar

Forkers

super-vip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.