Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oyvinev/log.sh
Logging library for Bash
https://github.com/oyvinev/log.sh
Last synced: 15 days ago
JSON representation
Logging library for Bash
- Host: GitHub
- URL: https://github.com/oyvinev/log.sh
- Owner: oyvinev
- License: mit
- Created: 2012-01-23T14:50:29.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2021-02-17T08:57:20.000Z (over 3 years ago)
- Last Synced: 2024-10-11T19:16:40.611Z (about 1 month ago)
- Language: Shell
- Homepage:
- Size: 9.77 KB
- Stars: 22
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.mkd
- Changelog: CHANGES.mkd
- License: COPYING
Awesome Lists containing this project
README
log.sh
======**log.sh** is a Bash library for easy logging with preset configurations.
Installation
------------make install
You can also use `PREFIX=$HOME` to install `log.sh` to `~/bin`, or any other location.
Example
-------Please run the `example.sh`, the following screenshot was taken from the output of version 0.1.
![Screenshot from v0.1 example.sh](http://1.bp.blogspot.com/-C4ina8EsnG8/Tx11fpAzEcI/AAAAAAAAC_Y/_-9WjbSOZgs/s1600/2012-01-23--22%253A51%253A57.png)
Usage
-----source /path/to/log.sh
# You are good to go
LSERROR Test error message
# or you can pipe the message
echo Test error message via pipe | LSERROR### Logging levels
LS_DEBUG_LEVEL=10
LS_INFO_LEVEL=20
LS_WARNING_LEVEL=30
LS_ERROR_LEVEL=40
LS_CRITICAL_LEVEL=50The default logging level is `LS_WARNING_LEVEL` and the value is stored at `LS_LEVEL`. If you need debug or info message, set `LS_LEVEL` to them.
### Default levels logging functions
LSDEBUG
LSINFO
LSWARNING
LSERROR
LSCRITICALAll arguments supplied to these function are treated as the message. There is also a general logging function `LSLOG`:
LSLOG 35 A message for level 35
The first parameter is the level. You do not need to use preset levels actually, as long as the level is equal to or greater than `LS_LEVEL`, the message will be printed out.
### Changing the output target
The default `LS_OUTPUT` is set to `/dev/stdout`, you can change it to `/dev/stderr` or any filename. Note that, it overwrites the file.
Support
-------Please use Issues to request features or to report bugs.
Help
----This library is relatively new and many things may not be considered by mistakes, please feel free to fork it and improve it, then open pull requests. Anything, coding, examples, documentations, ideas, even typo fixing are all welcome.
License
-------**log.sh** is licensed under the MIT License, please see COPYING.
Copyright (c) 2012 Yu-Jie Lin