Skip to content

lanthean/gbf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Generic Bash Functions

Purpose

Set of bash functions useful at all times.

Functions list

Default log level is "info". Can be changed by setting $LOG_LEVEL.

log

Log messages with severity ([d]ebug|[i]nfo|[w]arning|[e]rror) to stdout or $LOG_FILE if set.

log <severity> <message>
EXAMPLE
log i "This is a log message with severity info"

LOG_FILE will contain:
2019-04-02 14:02:53 CEST | ESC[0;32m[i]ESC[0m This is a log message with severity info

stdout will contain (while the [i] will be green):
2019-04-02 14:02:53 CEST | [i] This is a log message with severity info

sys_log

Log message with severity prefix (debug|info|warning|error) to /var/log/local6.

sys_log <severity> <message>
EXAMPLE
sys_log info "This is a log message with severity prefix info"

/var/log/local6 will contain:
2019-04-02T12:07:23.199934+00:00 rnd-vm-10-198 -bash[12662]: [info] This is a log message with severity prefix info

progress_bar

Display waiting pattern until a process finishes

progress_bar <$PID>
EXAMPLE
progress_bar 37458

# Below lines are displayed in one line, here multiple lines are used to articulate what is shown.
[processing of 37550] \
[processing of 37550] |
[processing of 37550] /
[processing of 37550] -

# Below line is displayed once the $PID has stopped, this line overwrites the above.
# Once the processing of the $PID stopped, only below lines remains in the terminal scroll view.
[processing of 37550] has finished

Usage

pushd /opt
git clone https://github.com/lanthean/gbf.git
ln -snf ./gbf generic_bash_functions
popd
source /opt/gbf/generic_bash_functions

Contact me

e [email protected]
g https://github.com/lanthean

About

Generic Bash Functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages