• Stars
    star
    43
  • Rank 645,449 (Top 13 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 8 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lumberjack is a logging interface for shell scripts

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

More Repositories

1

revolver

A progress spinner for ZSH scripts
Shell
143
star
2

crash

Proper error handling, exceptions and try/catch for ZSH
Shell
64
star
3

filthy

A disgustingly clean ZSH prompt
Shell
43
star
4

bushwick

# Bushwick
CSS
31
star
5

tipz

Gives you helpful hints when you execute a command for which you have an alias defined
Shell
27
star
6

browserWrapper

browserWrapper plugin, by @molovo
CSS
21
star
7

zlint

A linter and code style checker for ZSH
Shell
16
star
8

taken

An anchor CMS theme
CSS
15
star
9

zvm

The ZSH version manager
Shell
13
star
10

roots-image-pipeline

Image pipeline plugin for Roots (http://roots.cx)
CoffeeScript
13
star
11

color

A small zsh script for styling strings
Shell
12
star
12

sublime-zsh

Provides native ZSH autocompletion and snippets
Shell
11
star
13

anchor-comments

A plugin utilising the existing Anchor CMS comments functionality to provide inline comments within articles.
JavaScript
10
star
14

herd

A simple module to help with running multi-threaded processes in Crystal
Crystal
7
star
15

browserWrapper-lite

CSS
6
star
16

crayon

A collection of helpers for building pretty command-line tools in Crystal.
Crystal
6
star
17

zshbuild

A helper tool for building large ZSH projects from source
Shell
5
star
18

micro-stripe-payment

An asynchronous HTTP micro-service for accepting Stripe payments on static sites.
JavaScript
4
star
19

consumer

A tiny REST API consumer for JavaScript projects
JavaScript
4
star
20

accidents

Pretty error handling for command-line PHP apps.
PHP
4
star
21

.files

Vim Script
3
star
22

melody

A simple SASS framework
CSS
3
star
23

tiny

A Crystal module to help you build multi-threaded HTTP micro-services
Crystal
3
star
24

www

Sass
2
star
25

magic-roundabout

A tiny JavaScript carousel
JavaScript
2
star
26

done

A simple helper script to send a notification when a long-running command completes
Shell
2
star
27

graphite

A collection of helpers for building pretty command-line tools in PHP.
PHP
2
star
28

browserWrapper-site

HTML
2
star
29

live-node-list

An alternative to NodeList which keeps collections up to date when changes to the DOM occur
JavaScript
2
star
30

alternatone-stark-sea-syntax

CSS
1
star
31

timeme

TimeMe,
JavaScript
1
star
32

phake

A PHP task runner inspired by Make, Rake et al.
PHP
1
star
33

crsh

Crystal
1
star
34

object

HTML
1
star
35

Dates

A polyfill to recreate Google Chrome's keyboard input behaviour on date inputs across other browsers
JavaScript
1
star
36

insert-sudo

A little zsh snippet to prepend sudo to the current command
Shell
1
star
37

amnesia

A lightweight, standalone caching library for PHP 5.5+
PHP
1
star
38

load-graph

Shell
1
star
39

interrogate

A lightweight, standalone ORM for PHP 5.5+
PHP
1
star
40

dateme

Simple, non-invasive JavaScript date sanitisation.
JavaScript
1
star