TwP / logging

A flexible logging library for use in Ruby programs based on the design of Java's log4j library.
https://rubygems.org/gems/logging
MIT License
529 stars 100 forks source link

Support UTC offset #157

Closed TwP closed 7 years ago

TwP commented 7 years ago

The goal of this PR is to allow the timestamps generated by the various layout classes to be represented in specific timezones. Currently only the system local timezone is used when generating timestamps. The changes in this PR allow the user to configure a utc_offset for timestamps. With this setting enabled, layouts will adjust times to the desired utc_offset before formatting the timestamp.

Logging.utc_offset = "UTC"

With the above configuration, all timestamps for all layouts will be formatted in the UTC timezone. The layouts themselves can override this default when they are first created.

Logging.utc_offset = "+01:00"
Logging.layouts.json(:utc_offset => "UTC")  # times are formatted in UTC
Logging.layouts.pattern  # times are formatted in Central European Time "+01:00"

fixes #156

/cc @andrewtran634 just FYI