Skip to content

hfuchs/tinylog.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinylog.sh
============
2011-09-13, HF

tinylog.sh tries to be a small logging & debugging library for Bash
(actually any POSIX-conforming shell [read dash]) that requires exceedingly
little mental effort to use in everyday scripting.  Being almost as minimal
as it can get away with, it is also well-nigh non-configurable.  So,

WARNING: Right now, this is very much proof-of-concept material!

Usage
-------

Just say

    . ${0%/*}/tinylog.sh       # or  `dirname $0`/tinylog.sh  :)

or even

    . tinylog.sh               # if tinylog's in your $PATH.

and any output (stdout & stderr) will be written to a log file in $TMPDIR.
If you want a permanent logfile, just say so:

    logfile="$(dirname $0)/my.log"   # or something like it.
    . ${0%/*}/tinylog.sh

Then, in your script, use

    debug    "A message.  Only displayed when run interactively."
    error    "Severe message.  Goes to syslog in addition to stdout and the log."
    warn     "Same as error, lower panic level."
    printlog # Dump log contents to stdout (not the redirected one).

On the other hand, you'll have to keep in mind that `echo`s will leave
traces only in the log file.  Except, of course, if you use

    echo "Hello" >&$stdout

That's it.  If you want anything else, go fork yourself (a copy of this
repo)!


Further notice
---------------------

All files GPLv3-licensed and "Copyright 2011, Hagen Fuchs" (if you're
into this sort of thing [and if so, don't - for the love of God! - ever
contact me {except, of course, you know how I can GPL-protect my code
without those ludicrous disclaimers everywhere}]).  See COPYING if you
want a peek at the GPL.

I'll add a CREDITS and more flesh if anyone finds this helpful.


About

A logging & debugging library for Bash with little overhead (mental or otherwise)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages