FilterLog
FilterLog is a simple log that allows you to filter on which log messages get displayed by using tags.
Dependencies
FilterLog uses the colored gem to color output.
Usage
.debug
and .error
FilterLog provides two functions for showing output, both of which render using puts
.
These functions are .debug
and .error
.
.debug
will render a string out like so:
.error
will render a string out like so:
Using tags
You can pass tags in to your log calls that the FilterLog class will use to determine whether or not to show a given log message.
By default, no tags are enabled. This means that the following call will render nothing:
FilterLog.debug("Jordan rules", :my_tag)
To enable a tag, you can use:
FilterLog.enableTags(:my_tag, :my_other_tag)
To disable a tag you can use:
FilterLog.disableTags(:my_tag, :my_other_tag)
The purpose of using tagging is so you can reduce the amount of crap you see in your logs.
You can add as many tags as you want to a given log statement, so the following also works:
FilterLog.debug("Jordan rules", :my_tag, :hedonism, :other_tag, :something_else)
Tags can be anything, so if you want to see logs only for a given object, you can do the following:
jordan = Object.new
FilterLog.enableTags(jordan)
FilterLog.debug("I am a log", jordan)