class Giblish::AsciidoctorLogger::UserInfoFormatter
log formatter specialized for formatting messages from asciidoctor's stdout
Constants
- SEVERITY_LABELS
Public Instance Methods
call(severity, datetime, progname, msg)
click to toggle source
The hash that can be emitted as the msg from asciidoctor have the following format: {:text=>“…”,
:source_location=>#<Asciidoctor::Reader::Cursor:0x000055e65a8729e0 @file="<full adoc filename>", @dir="<full src dir>", @path="<only file name>", @lineno=<src line no>
}
# File lib/giblish/utils.rb, line 52 def call(severity, datetime, progname, msg) message = case msg when ::String msg when ::Hash # asciidoctor seem to emit a hash with error text and source location info # for warnings and errors str = String.new("") src_loc = msg.fetch(:source_location, nil) err_txt = msg.fetch(:text, nil) str << "Line #{src_loc.lineno} - " if src_loc str << err_txt.to_s if err_txt str else msg.inspect end %(#{datetime.strftime('%H:%M:%S')} #{progname}: #{SEVERITY_LABELS[severity] || severity}: #{message}\n) end