Let's face it - plain old echo just doesn't cut it. log4bash is an attempt to have better logging for Bash scripts (i.e. make logging in Bash suck less).
source the log4bash.sh script at the beginning of any Bash program.
#!/usr/bin/env bash source log4bash.sh log "This is regular log message... log and log_info do the same thing"; log_warning "Luke ... you turned off your targeting computer"; log_info "I have you now!"; log_success "You're all clear kid, now let's blow this thing and go home."; log_error "One thing's for sure, we're all gonna be a lot thinner."; # If you have figlet installed -- you'll see some big letters on the screen! log_captains "What was in the captain's toilet?"; # If you have the "say" command (e.g. on a Mac) log_speak "Resistance is futile";
An Overview of log4bash
Prints an "INFO" level message to stdout with the timestamp of the occurrence.
Prints a "WARNING" level message to stdout with the timestamp of the occurrence.
Prints a "SUCCESS" level message to stdout with the timestamp of the occurrence.
Prints an "ERROR" level message to stdout with the timestamp of the occurrence.
Special Logging Abilities
On the Mac platform this will use the say command to echo the command to the current audio output device.
If the figlet program is installed this will print out an ascii-art depiction of the phrase passed to the function.
Posts a message to your campfire configured by setting the variables for CAMPFIRE_API_AUTH_TOKEN and CAMPFIRE_NOTIFICATION_URL.
Other Useful Tidbits
A global array of all the arguments used to create run your script
The script name (sometimes tricky to get right depending on how one invokes a script).
The script's base directory which is not always the current working directory.
More to Come
Please add any feature requests to a ticket for this project.