GithubHelp home page GithubHelp logo

lumberjack's Introduction

Lumberjack

Lumberjack is a logging interface for shell scripts.

About

Lumberjack handles your logs for you. When you set a logfile and log level, it is linked to the process ID of the script in which it is run, so that further calls need only contain the message to append to the logfile.

Installation

Requirements

Although lumberjack can be used within any script, ZSH 5+ must be installed and in your $PATH in order to run it.

Zulu

zulu install lumberjack

Manual

Simply move the lj executable to somewhere in your $PATH.

git clone https://github.com/molovo/lumberjack
mv lumberjack/lj /usr/local/bin

Usage

Lumberjack should be called a first time to set the log file and level.

lj --file /usr/local/var/log/myawesomescript.log --level critical

Once done, further calls need only contain the level at which that log applies, and the message.

lj critical ‘Something went wrong’

The level is any one of emergency, alert, critical, error, warning, notice, info or debug. If the level is not set, the default is notice. Likewise, when logging you can omit the first parameter, and a level of notice is assumed.

lj 'This is a notice'

If a message is logged at a level lower than that which is set, it is gracefully ignored. This allows you to dynamically set the log level based on parameters passed to your script.

#!/usr/bin/env zsh

# Parse CLI options
zparseopts -D v=verbose -verbose=verbose

# Set the log level
local level=critical
[[ $verbose ]] && level=notice

# Initialise lumberjack
lj --file ~/log --level $level

lj 'This is a notice'

In the above example, running script.zsh would result in nothing being output to the log. Running script.zsh --verbose would increase the log level, allowing the notice to be appended to the log file.

TODO

  • Allow log format to be modified
  • Add additional drivers for send logs to services like Sentry etc.

License

Copyright (c) 2016 James Dinsdale [email protected] (molovo.co)

Lumberjack is licensed under The MIT License (MIT)

Team

lumberjack's People

Contributors

molovo 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.