Code Monkey home page Code Monkey logo

bash-logger's Introduction

Bash Logger

A logger for bash

Bash Logger gives you powerful logging for your bash scripts including:

  • Log levels
  • Logging channels
  • Logging context

Usage

Just source the src/index file with max-level, channel and optional prefix positional arguments in a suitable place for your project, and then call the relevant log level function with a message and optional context.

source [path/2/bash-logger/]src/index "INFO" path/2/file.log

log::debug "This is a debug message"
# no output as the log-level 'DEBUG' was not reached

log::info "This is an info message"
# output: [TIMESTAMP] INFO - This is an info message

Arguments

Max Level

The first argument to bash-logger is a string representing the maximum level that logging should reach. This allows different levels of logging to be set in different environments. Available levels in ascending order are:

  • EMERGENCY
  • ALERT
  • CRITICAL
  • ERROR
  • WARNING
  • NOTICE
  • INFO
  • DEBUG

Channel

The channel can be used to direct logging output, which can be any writeable file or terminal โ€“ using, for instance, $(tty).

Prefix

A prefix on all log messages can also be set by optionally passing in a string as the third argument to the source file call. Setting a prefix can improve readability of log messages.

bash-logger's People

Contributors

tomchkk avatar

Watchers

James Cloos avatar  avatar

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.