dpla/KriKri — pull request #41 by markbreedlove (2014-12-23 17:43:02+00:00)
Title: Add tagged logging to SoftwareAgent

This adds tagged logging to classes that extend SoftwareAgent, so you can do, e.g., `log :info "message"` within the context of an instance or class method. The generated log message will look similar to this:
```
[2014-12-23 16:47:59 +0000] [14146] [Krikri::Harvesters::OAIHarvester] created activity 1
```
It's tagged with a timestamp, PID, and the name of the class that generated it.

I was considering adding the following to map method calls like `log_info` to their respective Logger methods, but I took it out:
```
def method_missing(method_name, *args, &block)
method_s = method_name.to_s
if method_s[0,4] == 'log_'
priority = method_s.split('_')[1]
log(priority, *args)
else
super(method_name, *args, &block)
end
end
```

Rubocop complains about a couple of things that I'll highlight below.

Also, this is just plain file logging, which I think is all we should spend time on at the moment. With queue worker processes, it's probably best in the long term if they log to syslog or a database (Elasticsearch?), or otherwise have their messages centrally aggregated.