Recent Releases of https://github.com/bdurand/lumberjack
https://github.com/bdurand/lumberjack - v2.0.4
Fixed
- Hardened multi-threaded context locals handling to ensure compatibility with all Ruby implementations.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v2.0.3...v2.0.4
- Ruby
Published by bdurand about 2 months ago
https://github.com/bdurand/lumberjack - v2.0.3
Added
- Added
isolation_levelto loggers. By default this is set to:fiberwhich isolates logger contexts to the current fiber. That is each fiber will get its own context stack and starting a new fiber will start with a clean context. Settingisolation_levelto:threadwill isolate contexts to the current thread instead. This is useful if your application does not share fibers between threads and you want to maintain context across fibers in the same thread.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v2.0.2...v2.0.3
- Ruby
Published by bdurand 4 months ago
https://github.com/bdurand/lumberjack - v2.0.2
Changed
- Attempts to use the logger inside a logging call (e.g. from a in a formatter) will now print the log message to STDERR. Previously such log messages would be silently dropped in order to prevent infinite recursion.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v2.0.1...v2.0.2
- Ruby
Published by bdurand 4 months ago
https://github.com/bdurand/lumberjack - v2.0.1
Fixed
- Merge attributes in forked loggers in the correct order so that attributes from the forked logger override those from the parent logger.
- Ruby
Published by bdurand 4 months ago
https://github.com/bdurand/lumberjack - v2.0.0
This is a major update with several breaking changes. See the upgrade guide for details on breaking changes.
Added
- Added
Lumberjack::EntryFormatterclass to provide a unified interface for formatting log entry details. Going forward this is the preferred way to define log entry formatters.Lumberjack::Logger#formatternow returns an entry formatter. - Added
Lumberjack::Logger#tag!as the preferred method for adding global tags to a logger. - Added
Lumberjack::Logger#untag!to remove global tags from a logger. - Added
Lumberjack::Logger#in_context?as a replacement forLumberjack::Logger#in_tag_context?andLumberjack.in_context?as a replacement forLumberjack.context?. - Added
Lumberjack::Logger#tag_all_contextsas a means to add attributes to parent context blocks. This allows setting attributes for the scope of the outermost context block. - Added
ensure_contextmethods toLumberjackandLumberjack::Loggerto ensure that a logging context exists and only create one if necessary. - Added IO compatibility methods for logging. Calling
logger.write,logger.puts,logger.print, orlogger.printfwill write log entries. The severity of the log entries can be set withdefault_severity. - Added
Lumberjack::Device::LoggerWrapperas a device that forwards entries to another Lumberjack logger. - Added
Lumberjack::Device::Testclass for use in testing logging functionality. This device will buffer log entries and hasmatch?andinclude?methods that can be used for assertions in tests. - Added support for standard library
Logger::Formatter. This is for compatibility with the standard libraryLogger. If a standard library logger is passed toLumberjack::Loggeras the formatter, it will override the template when writing to a stream. Tags are not available in the output when using a standard library formatter. - Classes can now define their own formatting in logs by implementing the
to_log_formatmethod. If an object responds to this method, it will be called in lieu of looking up the formatter by class. This allows a pattern of defining log formatting along with the code rather than in a an initializer. - Tag formatters can now add class formatters by class name using the
add_classmethod. This allows setting a class formatter before the class has been loaded. - A tag format can now be passed to the
Lumberjack::Templateclass to specify how to format tag name/value pairs. The default is "[%s:%s]". - Added
TRACElogging level for logging at an even lower level thanDEBUG.Lumberjack::Logger#tracecan be used to log messages at this level. - Added
Lumberjack::ForkedLoggerwhich is a wrapper around a logger with a separate context. A forked logger has a parent logger which it will write its log entries through. It will inherit the level, progname, and tags from a parent logger, but has its own local context isolated from the parent logger. You can change the level, progname, and add tags on the forked logger without impacting the parent logger. Forked loggers can be obtained from the current logger by callingLumberjack::Logger#fork. - Added
Lumberjack::Utils.current_lineas a helper method for getting the current line of code. - Added
Lumberjack.build_formatteras a helper method for building entry formatters. - Added merge method on formatters to allow merging in formats from other formatters.
- Templates can now use variations on the severity label with a format option added to the placeholder:
{{severity(padded)}},{{severity(char)}},{{severity(emoji)}}, and{{severity(level)}}. - Log entries in templates can now be colorized by severity with the
colorize: true. - Added
Lumberjack::Formatter::Tagsfor formatting attributes as "tags" in the logs. Arrays of values will be formatted as "[val1] [val2]" and hashes will be formatted as "[key1=value1] [key2=value2]". - Added
Lumberjack::FormatterRegistryas a means of associating formatters with a symbol. Symbols can be used when adding class and attribute formatters. This extends the behavior previously limited to the built in formatters so that users can define their own formatters and register them for use. - Added
Lumberjack::DeviceRegistryas a means for associating devices with a symbol. Symbols can then be passed to the constructor when creating a logger and the logger will take care of instantiating the device. - Added
Lumberjack::TemplateRegistryas a means for associating templates with a symbol. Symbols can then be passed to the logger constructor in lieu of the template definition. - Added
Lumberjack::Logger#clear_attributesto remove all attributes from the logger. - Added
Lumberjack::MessageAttributesto replaceLumberjack::Formatter::TaggedMessage. - Added
Lumberjack::RemapAttributeto facilitate attribute remapping in attribute formatters.
Changed
Lumberjack::Loggernow inherits from::Loggerinstead of just having API compatibility with the standard libraryLoggerclass.- Breaking Change The default log level is now DEBUG instead of INFO.
- The severity label for log entries with an unknown level is now ANY instead of UNKNOWN.
- Breaking Change Changing logger level or progname inside a context block will now only be in effect inside the block.
- Breaking Change
LumberJack::Logger#contextnow yields aLumberjack::Contextrather than aLumberjack::TagContext. It must be called with a block and can no longer be used to return the current context.Lumberjack.contextmust also now be called with a block. Lumberjack::TagContexthas been renamed toLumberjack::AttributesHelper.Lumberjack::TagFormatterhas been renamed toLumberjack::AttributeFormatter.- Breaking Change
Lumberjack::Formatterno longer includes any default formats. You can still get the default formatter withLumberjack::Formatter.default. You can use theincludemethod to merge in the default formats from this formatter. You can also use the default formatter by passing informatter: :defaultin the logger constructor. Theemptymethod has been deprecated since it is no longer needed. Lumberjack::Logger#add_entrydoes not check the logger level and will add the entry regardless of the severity. This method is an internal API method and is now documented as such.- Logging to files will now use the standard library
Logger::LogDeviceclass for file output and rolling. - The
Lumberjack::Device::Writerclass now takes anautoflushoption. Setting it to false will disable synchronous I/O. Lumberjack.tagcan now be called with a block to set up a new context.
Removed
- Breaking Change Removed deprecated unit of work id code. These have been replaced with tags.
- Breaking Change Removed deprecated support for setting global tags with
Lumberjack::Logger#tag. Now callingtagoutside of a block or context will be ignored. Usetag!to set global tags on a logger. - Removed internal buffer from the
Lumberjack::Device::Writerclass. This functionality was more useful in the days of slower I/O operations when logs were written to spinning hard disks. The functionality is no longer as useful and is not worth the overhead. TheLumberjack::Logger.last_flushed_atmethod has also been removed. If you need buffered logging, use the newLumberjack::Device::Bufferclass to wrap another device. - Breaking Change When adding a formatter with
Lumberjack::Formatter#addyou can no longer pass the formatter as a class name (i.e. this won't work: `formatter.add(MyClass, "Lumberjack::Formatter::IdFormatter"); the formatter can be a class, symbol, callable object, or a block). - Removed support for Ruby versions < 2.7.
Deprecated
Lumberjack::Loggernow takes keyword arguments instead of an options hash. If you were passing in options as a hash, you now need to doublesplat it:Lumberjack::Logger.new(stream, **options).- "Tags" are now called "attributes" to better align with best practices. In logging parlance "tags" are generally an array of strings. The main interface to adding log attributes with
Lumberjack::Logger#taghas not changed. In this case we are using "tag" as a verb as in "to tag a log entry with attributes". The public interfaces that used "tag" in the method names have all been deprecated and will be removed in a future release.Lumberjack.context_tagsLumberjack::Logger#tagsLumberjack::Logger#tag_valueLumberjack::Logger#taggedLumberjack::Logger#silenceLumberjack::Logger#log_atLumberjack::Logger#untaggedLumberjack::Logger#tag_formatterLumberjack::Logger#in_tag_context?Lumberjack::Logger#tag_globallyLumberjack::Logger#remove_tagLumberjack::Logger#set_prognameLumberjack::LogEntry#tagLumberjack::LogEntry#tagsLumberjack::LogEntry#nested_tagsLumberjack::Utils.flatten_tagsLumberjack::Utils.expand_tagsLumberjack::TagContextLumberjack::TagFormatterLumberjack::TagFormatter#addLumberjack::TagFormatter#removeLumberjack::TagsLumberjack::Formatter::TaggedMessageLumberjack::Device::RollingLogFileLumberjack::Device::SizeRollingLogFile
- The Rails compatibility methods on
Lumberjack::Logger(tagged,silence,log_at) have been moved to the lumberjack_rails gem. Installing that gem will restore these methods in a non-deprecated form. - Templates now use mustache syntax for placeholders instead of the colon prefix (i.e.
{{message}}instead of:message). The:tagsplaceholder is also now called{{attributes}}.
- Ruby
Published by bdurand 4 months ago
https://github.com/bdurand/lumberjack - v1.4.2
Fixed
- Fixed issue where calling
Lumberjack::LogEntry#tagwould raise an error if there were no tags set on the log entry.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.4.1...v1.4.2
- Ruby
Published by bdurand 6 months ago
https://github.com/bdurand/lumberjack - v1.4.1
Changed
- Catch errors when formatting values so that it doesn't prevent logging. Otherwise there can be no way to log that the error occurred. Values that produced errors in the formatter will now be shown in the logs as "".
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.4.0...v1.4.1
- Ruby
Published by bdurand 6 months ago
https://github.com/bdurand/lumberjack - v1.4.0
Changed
- Tags are consistently flattened internally to dot notation keys. This makes tag handling more consistent when using nested hashes as tag values. This changes how nested tags are merged, though. Now when new nested tags are set they will be merged into the existing tags rather than replacing them entirely. So
logger.tag(foo: {bar: "baz"})will now merge thefoo.bartag into the existing tags rather than replacing the entirefootag. - The
Lumberjack::Logger#contextmethod can now be called without a block. When called with a block it sets up a new tag context for the block. When called without a block, it returns the current tag context in aLumberjack::TagContextobject which can be used to add tags to the current context. - Tags in
Lumberjack::LogEntryare now always stored as a hash of flattened keys. This means that when tags are set on a log entry, they will be automatically flattened to dot notation keys. Thetagmethod will return a hash of sub-tags if the tag name is a tag prefix.
Added
- Added
Lumberjack::LogEntry#nested_tagsmethod to return the tags as a nested hash structure.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.3.4...v1.4.0
- Ruby
Published by bdurand 7 months ago
https://github.com/bdurand/lumberjack - v1.3.4
Added
- Added
Lumberjack::Logger#with_prognamealias forset_prognameto match the naming convention used for setting temporary levels.
Fixed
- Ensure that the safety check for circular calls to
Lumberjack::Logger#add_entrycannot lose state.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.3.3...v1.3.4
- Ruby
Published by bdurand 7 months ago
https://github.com/bdurand/lumberjack - v1.3.3
Added
- Added
Lumberjack::Utils#expand_tagsmethod to expand a hash of tags that may contain nested hashes or dot notation keys.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.3.2...v1.3.3
- Ruby
Published by bdurand 7 months ago
https://github.com/bdurand/lumberjack - v1.3.2
Fixed
- Fixed
NoMethodErrorwhen setting the device via theLumberjack::Logger#device=method.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.3.1...v1.3.2
- Ruby
Published by bdurand 7 months ago
https://github.com/bdurand/lumberjack - v1.3.1
Added
- Added
Lumberjack::Logger#contextmethod to set up a context block for the logger. This is the same as callingLumberjack::Logger#tagwith an empty hash. - Log entries now remove empty tag values so they don't have to be removed downstream.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.3.0...v1.3.1
- Ruby
Published by bdurand 7 months ago
https://github.com/bdurand/lumberjack - 1.3.0
Added
- Added
Lumberjack::Formatter::TaggedMessageto allow extracting tags from log messages via a formatter in order to better support structured logging of objects. - Added built in
:roundformatter to round numbers to a specified number of decimal places. - Added built in
:redactformatter to redact sensitive information from log tags. - Added support in
Lumberjack::TagFormatterfor class formatters. Class formatters will be applied to any tag values that match the class. - Apply formatters to enumerable values in tags. Name formatters are applied using dot syntax when a tag value contains a hash.
- Added support for a dedicated message formatter that can override the default formatter on the log message.
- Added support for setting tags from the request environment in
Lumberjack::Rack::Contextmiddleware. - Added helper methods to generate global PID's and thread ids.
- Added
Lumberjack::Logger#tag_globallyto explicitly set a global tag for all loggers. - Added
Lumberjack::Logger#tag_valueto get the value of a tag by name from the current tag context. - Added
Lumberjack::Utils.hostnameto get the hostname in UTF-8 encoding. - Added
Lumberjack::Utils.global_pidto get a global process id in a consistent format. - Added
Lumberjack::Utils.global_thread_idto get a thread id in a consistent format. - Added
Lumberjack::Utils.thread_nameto get a thread name in a consistent format. - Added support for
ActiveSupport::Logging.logger_outputs_to?to check if a logger is outputting to a specific IO stream. - Added
Lumberjack::Logger#log_atmethod to temporarily set the log level for a block of code for compatibility with ActiveSupport loggers.
Changed
- Default date/time format for log entries is now ISO-8601 with microsecond precision.
- Tags that are set to hash values will now be flattened into dot-separated keys in templates.
Removed
- Removed support for Ruby versions < 2.5.
Deprecated
- All unit of work related functionality from version 1.0 has been officially deprecated and will be removed in version 2.0. Use tags instead to set a global context for log entries.
- Calling
Lumberjack::Logger#tagwithout a block is deprecated. UseLumberjack::Logger#tag_globallyinstead.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.2.10...v1.3.0
- Ruby
Published by bdurand 8 months ago
https://github.com/bdurand/lumberjack - v1.2.8
What's Changed
- Add Logger#untagged to remove previously set logging tags from a block.
- Return result of the block when a block is passed to Logger#tag.
Full Changelog: https://github.com/bdurand/lumberjack/compare/v1.2.7...v1.2.8
- Ruby
Published by bdurand almost 3 years ago