log-json_formatter
A Log::Formatter
for JSON-encoded logs to an IO
Installation
-
Add the dependency to your
shard.yml
:dependencies: log-json_formatter: github: dscottboggs/log-json_formatter
-
Run
shards install
Usage
require "log-json_formatter"
record CustomType, a = 1, b = 2 do
include ::Log::JSONFormatter::Loggable
def_to_metadata_value({a: @a, b: @b})
end
::Log.setup level: :trace,
backend: Log::IOBackend.new formatter: Log::JSONFormatter,
Log.info &.emit "example message", metadata: 1, values: %w[of any kind],
"even values of a": CustomType.new
Contributing
- Fork it (https://github.com/dscottboggs/log-json_formatter/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- D. Scott Boggs - creator and maintainer