
On 29 October 2014 12:13, Myles Braithwaite <me@mylesbraithwaite.com> wrote:
Dave Cramer wrote:
Is there anything out there that is written simply ? By this I mean I don't want to have to install a framework or a jvm or any large dependencies. Ideally this would be written in bash or the like.
You could use the sqlite. Running something like:
#!/bin/sh sqlite3 log.db 'INSERT INFO log (message) VALUES ($MESSAGE);'
in a table setup like this:
CREATE TABLE log ( id INTEGER PRIMARY KEY, timestamp DATETIME DEFAULT CURRENT_TIMESTAMP, message TEXT );
I'm finding I really like using command line tooling to write to syslog... The command "logger" <http://linux.die.net/man/1/logger> writes entries to syslog I populate shell scripts with wee "glog" functions to wrap this... glog () { local level=$1 local notice=$2 logger -i -p "${level}" -t "name-of-my-script.sh" "${notice}" echo "${level} ${notice}" } I then inject glog user.notice "Ooh, I did something!" and glog user.error "oops, something went wrong - rc=$?" and such. If I *really* wanted to, I could configure syslog to write some messages to a SQL database. <http://www.rsyslog.com/doc/rsyslog_pgsql.html> I did that for a while; found it to be more a pain than a help. (IPv6 issues blew up the logs on me, and I couldn't query the DB as fast as disk space ballooned away...) I'm finding that I [Heart] logger as a way of getting scripty apps to log activity. The OTHER thing I'd like is to have something materially better than cron, unfortunately, that's a surprisingly expensive problem. Improving on cron looks, historically, like it leads to the sort of all-encompassing framework expansion that is where (eek!) we're seeing controversies about SystemD. -- When confronted by a difficult problem, solve it by reducing it to the question, "How would the Lone Ranger handle this?"