asenchi/scrolls — pull request #54 by asenchi (2014-02-06 17:08:34+00:00)
Title: Major refactor of internal Log module

To address #53 this restructures our internal log object. Instead of a module we move to a class that is instantiated upon using `#init`. This breaks current Scrolls behavior in the following ways:

* The `global_context` is no longer mutable, instead we instantiate a class internally inside Scrolls::Logger that contains the `global_context`. This is to avoid various thread behavior that previous to Ruby 2.0 were allowed.
* The result of the above change removes `#add_global_context`.
* Currently Scrolls needs to be instantiated to be used (`Scrolls.init(options)`) however I'd like to work on a method for allowing one to just use `Scrolls.log` and get sane defaults.
* Due to this massive change I moved to "single line exceptions" by default since it lowers the amount of data produced by Scrolls when using `#log_exception` without losing the information.
* We drop support for Ruby 1.8.7.

I've currently got all tests passing:

```
projects/scrolls major-refactor! : rbenv local 2.1.0
projects/scrolls major-refactor! : rake
Run options: -v

# Running tests:

TestScrolls#test_add_timestamp = 0.00 s = .
TestScrolls#test_all_the_contexts = 0.00 s = .
TestScrolls#test_construct = 0.00 s = .
TestScrolls#test_context_after_exception = 0.00 s = .
TestScrolls#test_deeply_nested_context = 0.00 s = .
TestScrolls#test_deeply_nested_context_dropped = 0.00 s = .
TestScrolls#test_default_context = 0.00 s = .
TestScrolls#test_default_global_context = 0.00 s = .
TestScrolls#test_default_logging_levels = 0.00 s = .
TestScrolls#test_default_time_unit = 0.00 s = .
TestScrolls#test_level_translation_error = 0.00 s = .
TestScrolls#test_level_translation_fatal = 0.00 s = .
TestScrolls#test_level_translation_unknown = 0.00 s = .
TestScrolls#test_level_translation_warn = 0.00 s = .
TestScrolls#test_log_exception = 0.00 s = .
TestScrolls#test_logging = 0.00 s = .
TestScrolls#test_logging_block = 0.00 s = .
TestScrolls#test_logging_strings = 0.00 s = .
TestScrolls#test_multi_line_exceptions = 0.00 s = .
TestScrolls#test_setting_context = 0.00 s = .
TestScrolls#test_setting_global_context = 0.00 s = .
TestScrolls#test_setting_incorrect_time_unit = 0.00 s = .
TestScrolls#test_setting_syslog_facility = 0.00 s = .
TestScrolls#test_setting_syslog_facility_after_instantiation = 0.00 s = .
TestScrolls#test_setting_time_unit = 0.00 s = .
TestScrolls#test_syslog_facility = 0.00 s = .
TestScrolls#test_syslog_integration = 0.00 s = .
TestScrollsParser#test_parse_bool = 0.00 s = .
TestScrollsParser#test_parse_numbers = 0.00 s = .
TestScrollsParser#test_parse_strings = 0.00 s = .
TestScrollsParser#test_parse_time = 0.00 s = .
TestScrollsParser#test_unparse_constants = 0.00 s = .
TestScrollsParser#test_unparse_nil = 0.00 s = .
TestScrollsParser#test_unparse_time = 0.00 s = .

Finished tests in 0.012021s, 2828.3837 tests/s, 5074.4530 assertions/s.

34 tests, 61 assertions, 0 failures, 0 errors, 0 skips

ruby -v: ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
projects/scrolls major-refactor! : rbenv local 1.9.3
projects/scrolls major-refactor! : rake
Run options: -v

# Running tests:

TestScrolls#test_add_timestamp = 0.00 s = .
TestScrolls#test_all_the_contexts = 0.00 s = .
TestScrolls#test_construct = 0.00 s = .
TestScrolls#test_context_after_exception = 0.00 s = .
TestScrolls#test_deeply_nested_context = 0.00 s = .
TestScrolls#test_deeply_nested_context_dropped = 0.00 s = .
TestScrolls#test_default_context = 0.00 s = .
TestScrolls#test_default_global_context = 0.00 s = .
TestScrolls#test_default_logging_levels = 0.00 s = .
TestScrolls#test_default_time_unit = 0.00 s = .
TestScrolls#test_level_translation_error = 0.00 s = .
TestScrolls#test_level_translation_fatal = 0.00 s = .
TestScrolls#test_level_translation_unknown = 0.00 s = .
TestScrolls#test_level_translation_warn = 0.00 s = .
TestScrolls#test_log_exception = 0.00 s = .
TestScrolls#test_logging = 0.00 s = .
TestScrolls#test_logging_block = 0.00 s = .
TestScrolls#test_logging_strings = 0.00 s = .
TestScrolls#test_multi_line_exceptions = 0.00 s = .
TestScrolls#test_setting_context = 0.00 s = .
TestScrolls#test_setting_global_context = 0.00 s = .
TestScrolls#test_setting_incorrect_time_unit = 0.00 s = .
TestScrolls#test_setting_syslog_facility = 0.00 s = .
TestScrolls#test_setting_syslog_facility_after_instantiation = 0.00 s = .
TestScrolls#test_setting_time_unit = 0.00 s = .
TestScrolls#test_syslog_facility = 0.00 s = .
TestScrolls#test_syslog_integration = 0.00 s = .
TestScrollsParser#test_parse_bool = 0.00 s = .
TestScrollsParser#test_parse_numbers = 0.00 s = .
TestScrollsParser#test_parse_strings = 0.00 s = .
TestScrollsParser#test_parse_time = 0.00 s = .
TestScrollsParser#test_unparse_constants = 0.00 s = .
TestScrollsParser#test_unparse_nil = 0.00 s = .
TestScrollsParser#test_unparse_time = 0.00 s = .

Finished tests in 0.007418s, 4583.4457 tests/s, 8223.2408 assertions/s.

34 tests, 61 assertions, 0 failures, 0 errors, 0 skips
```

I'd like some review on this approach. If the following people wouldn't mind reviewing I would greatly appreciate it: @gorsuch @dpiddy @eric