log-json_formatter v2.0.1

(Crystal) A formatter for JSON-encoded logs to an IO

log-json_formatter

A Log::Formatter for JSON-encoded logs to an IO

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      log-json_formatter:
        github: dscottboggs/log-json_formatter
    
  2. 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

  1. Fork it (https://github.com/dscottboggs/log-json_formatter/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

Repository

log-json_formatter

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 0
  • about 2 years ago
  • August 28, 2022
License

Mozilla Public License 2.0

Links
Synced at

Fri, 22 Nov 2024 00:08:46 GMT

Languages