Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/molovo/lumberjack
Lumberjack is a logging interface for shell scripts
https://github.com/molovo/lumberjack
Last synced: about 2 months ago
JSON representation
Lumberjack is a logging interface for shell scripts
- Host: GitHub
- URL: https://github.com/molovo/lumberjack
- Owner: molovo
- License: mit
- Created: 2016-09-01T19:25:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-14T20:34:54.000Z (over 7 years ago)
- Last Synced: 2024-01-23T16:12:33.605Z (4 months ago)
- Language: Shell
- Homepage:
- Size: 9.77 KB
- Stars: 40
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-shell - lumberjack - A logging interface for shell scripts (Shell Script Development / Directory Navigation)
- awesome-zsh-plugins - lumberjack - Lumberjack is a logging interface for shell scripts. (Plugins / ZSH on Windows)
- awesome-shell - lumberjack - A logging interface for shell scripts (Shell Script Development / Directory Navigation)
- fucking-awesome-zsh-plugins - lumberjack - Lumberjack is a logging interface for shell scripts. (Plugins / ZSH on Windows)
- awesome-zsh-plugins - lumberjack - Lumberjack is a logging interface for shell scripts. (Plugins / Zinit (née zplugin))
- awesome-shell - lumberjack - A logging interface for shell scripts (Shell Script Development)
- awesome-zsh-plugins - lumberjack - Lumberjack is a logging interface for shell scripts. (Plugins / ZSH on Windows)
README
# 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](https://github.com/zulu-zsh/zulu)
```sh
zulu install lumberjack
```### Manual
Simply move the `lj` executable to somewhere in your $PATH.
```sh
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.
```sh
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.
```sh
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.
```sh
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.
```sh
#!/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 $levellj '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](http://sentry.io) etc.## License
Copyright (c) 2016 James Dinsdale (molovo.co)
Lumberjack is licensed under The MIT License (MIT)
## Team
* [James Dinsdale](http://molovo.co)