asenchi / scrolls

Simple logging
MIT License
158 stars 26 forks source link

Major refactor of internal Log module #54

Closed asenchi closed 7 years ago

asenchi commented 10 years ago

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:

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

asenchi commented 10 years ago

Also /cc @slemiere since this reverts his feature in #33.

asenchi commented 10 years ago

Heh just realized that I simultaneously supported 1.8.7 in our parser tests and dropped it for the project as a whole.

spicycode commented 10 years ago

@asenchi Nice. Looking forward to this landing

gorsuch commented 10 years ago

All of this seems reasonable to me and like a step in the right direction. I prefer instantiation.

gregburek commented 10 years ago

Now that ruby 1.9.3 is in security fixes only mode I am very excited to get this merged and deployed! Do you need any help or alpha testers for this change?

grantr commented 10 years ago

@asenchi can you give an example of the new single line exception log format?

asenchi commented 7 years ago

I will be working to refactor this code since it has sat stale for so long. Apologies for my lax behavior here. I cut a new release with the current behavior here in preparation for this work.

asenchi commented 7 years ago

Replaced by #71.