-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change log level from number to log name #83
Comments
Please make suitable formatter for your project referring to https://github.com/tilfin/ougai/blob/master/lib/ougai/formatters/bunyan.rb. For example, require 'rubygems'
require 'ougai'
class YourFormatter < Ougai::Formatters::Base
include Ougai::Formatters::ForJson
def initialize(app_name = nil, hostname = nil, opts = {})
aname, hname, opts = Ougai::Formatters::Base.parse_new_params([app_name, hostname, opts])
super(aname, hname, opts)
init_opts_for_json(opts)
end
def _call(severity, time, progname, data)
dump({
name: progname || @app_name,
hostname: @hostname,
pid: $$,
level: severity.downcase,
time: time,
v: 0
}.merge(data))
end
def convert_time(data)
data[:time] = format_datetime(data[:time])
end
end
logger = Ougai::Logger.new(STDOUT)
logger.formatter = YourFormatter.new
logger.info('a message', foo: 100)
|
i am wired too why we use number instead level name, thank you. |
If the log level is numeric, the log service can filter the logs easily like |
thank you, kibanba can use: 'level > 30' directly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I try to print the below log, it prints "level" in numbers. Instead, I want it in the log level name itself.
logger.info('Information!') {"name":"main","hostname":"mint","pid":14607,"level":30,"time":"2016-10-16T22:26:48.835+09:00","v":0,"msg":"Information!"}
Am expecting,
logger.info('Information!') {"name":"main","hostname":"mint","pid":14607,"level":"Info","time":"2016-10-16T22:26:48.835+09:00","v":0,"msg":"Information!"}
How to do this?
The text was updated successfully, but these errors were encountered: