log_lib message logging and printing library

log_lib 1.0

What is it?
A set of functions and constants for controlling printing of errors, warnings, informational, and debugging messages in scripts.

Users can set the property log_verbosity to control how chatty scripts that use this library are.

Script developers can use log_fatal(string), log_error(string), log_warning(string), log_info(string), log_debug(string) instead of print, then dynamically control which ones actually generate output by setting the global variable log_verbosity to the level of verbosity they want in the script (e.g. log_verbosity = log_FATAL; to only print fatal errors, or log_verbosity = log_DEBUG; to see all the internal debugging messages you define.)

In addition all of the log_* methods return false for convenience.

Note: Depends on zarqon's excellent zlib.ash make sure you install that first.

For Users
Set the property log_verbosity to silent, fatal, error, warning, info, debug (in increasing order of verbosity) to control how chatty scripts that use this library are. Higher levels of verbosity include all lower levels as well.

For Script Authors

Methods

boolean log_fatal(string msg)
boolean log_error(string msg)
boolean log_warning(string msg)
boolean log_info(string msg)
boolean log_debug(string msg)

Call these in your code to conditionally print messages at different verbosity levels.

During development, you can set the global variable log_verbosity to one of:

log_SILENT
log_FATAL
log_ERROR
log_WARNING
log_INFO
log_DEBUG

to dynamically control printing of messages.

Change Log
1.0 2009/11/18 Initial release
 

Attachments

  • log_lib.ash
    1.6 KB · Views: 150
Last edited:
Top