<img src=“https://secure.travis-ci.org/fredemmott/my_stuff-logger.png” /> <img src=“https://gemnasium.com/fredemmott/my_stuff-logger.png” />

What is this?

A drop-in replacement for Ruby’s standard Logger class, if you’re just using the basic features.

How do I get it?

gem install my_stuff-logger

How do I use it?

Create an instance, then just like the standard Logger class; take a look at example.rb.

Why would I use it instead?

It’s got more information.

  • The filename, line number, and method are always included

  • By default, a backtrace is included for errors and fatals. This can be tuned to any level, including even for debug, or for none at all.

File names are shown relative to a choosable root (which defaults to File.dirname(File.expand_path($0))) — if a file isn’t in that root, you get the full path, not ‘../../../../../../foo/bar/baz’ :p

It’s easier to see what’s important.

You can choose what’s relevant.

There’s per-app settings for where output goes, what levels are logged, and what levels get backtraces — but you can also change this per-instance, and it’ll stick that way even if the global is changed later.

You can also change the defaults via environment variables:

  • MYSTUFF_LOGLEVEL

  • MYSTUFF_BTLEVEL

You can plug in your own filters to make the log messages more readable.

A couple of examples:

  • The priority colorization is a filter

  • There’s also a filter shipped (but not enabled by default) for use with MyStuff::MultiDB, which turns ‘Foo::MYSTUFF_MULTIDB_DB_aloadofhex::Bar’ into ‘Foo::<localhost:3307/test>::Bar’

These filters are only enabled for log viewing; they don’t affect what’s written to disk.

By default, colors are enabled if the output device (STDOUT usually) is a TTY, but disabled otherwised — of course, this can be overidden.

It’s easier/faster to machine-process.

  • The number in the second field is a unix timestamp

  • The filename is always in the same place, in the same format, making it easier to use with grep, or something more in-depth.

What’s coming soon?

  • a ‘msl-cat’ command, applying the filters

  • a ‘msl-tail’ command, emulating/wrapping ‘tail -F’