Class: RailsSemanticLogger::Options
- Inherits:
-
Object
- Object
- RailsSemanticLogger::Options
- Defined in:
- lib/rails_semantic_logger/options.rb
Overview
Options for controlling Rails Semantic Logger behavior
-
Convert Action Controller and Active Record text messages to semantic data
Rails -- Started -- { :ip => "127.0.0.1", :method => "GET", :path => "/dashboards/inquiry_recent_activity" } UserController -- Completed #index -- { :action => "index", :db_runtime => 54.64, :format => "HTML", :method => "GET", :mongo_runtime => 0.0, :path => "/users", :status => 200, :status_message => "OK", :view_runtime => 709.88 } config.rails_semantic_logger.semantic = true -
Change Rack started message to debug so that it does not appear in production
config.rails_semantic_logger.started = false -
Change Processing message to debug so that it does not appear in production
config.rails_semantic_logger.processing = false -
Change Action View render log messages to debug so that they do not appear in production
ActionView::Base -- Rendered data/search/_user.html.haml (46.7ms) config.rails_semantic_logger.rendered = false -
Override the Amazing Print options for logging Hash data as text:
Any valid Amazing Print option for rendering data. The defaults can changed be creating a `~/.aprc` file. See: https://github.com/amazing-print/amazing_print Note: The option :multiline is set to false if not supplied. Note: Has no effect if Amazing Print is not installed. config.rails_semantic_logger.ap_options = {multiline: false} -
Whether to automatically add an environment specific log file appender.
For Example: 'log/development.log' Note: When Semantic Logger fails to log to an appender it logs the error to an internal logger, which by default writes to STDERR. Example, change the default internal logger to log to stdout: SemanticLogger::Processor.logger = SemanticLogger::Appender::IO.new($stdout, level: :warn) config.rails_semantic_logger.add_file_appender = true -
Silence asset logging
config.rails_semantic_logger.quiet_assets = false -
Disable automatic logging to stderr when running a Rails console.
config.rails_semantic_logger.console_logger = false -
Override the output format for the primary Rails log file.
Valid options: * :default Plain text output with no color. * :color Plain text output with color. * :json JSON output format. * class * Proc A block that will be called to format the output. It is supplied with the `log` entry and should return the formatted data. Note: * `:default` is automatically changed to `:color` if `config.colorize_logging` is `true`. JSON Example, in `application.rb`: config.rails_semantic_logger.format = :json Custom Example, create `app/lib/my_formatter.rb`: # My Custom colorized formatter class MyFormatter < SemanticLogger::Formatters::Color # Return the complete log level name in uppercase def level "#{color}log.level.upcase#{color_map.clear}" end end # In application.rb: config.rails_semantic_logger.format = MyFormatter.new config.rails_semantic_logger.format = :default -
Add a filter to the file logger [Regexp|Proc] RegExp: Only include log messages where the class name matches the supplied
regular expression. All other messages will be ignored.Proc: Only include log messages where the supplied Proc returns true.
The Proc must return true or false. config.rails_semantic_logger.filter = nil -
named_tags: DEPRECATED Instead, supply a Hash to config.log_tags config.rails_semantic_logger.named_tags = nil
-
Change the message format of Action Controller action. A block that will be called to format the message. It is supplied with the
messageandpayloadand should return the formatted data.config.rails_semantic_logger. = -> (, payload) do "#{} - #{payload[:controller]}##{payload[:action]}" end
Instance Attribute Summary collapse
-
#action_message_format ⇒ Object
Returns the value of attribute action_message_format.
-
#add_file_appender ⇒ Object
Returns the value of attribute add_file_appender.
-
#ap_options ⇒ Object
Returns the value of attribute ap_options.
-
#console_logger ⇒ Object
Returns the value of attribute console_logger.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#format ⇒ Object
Returns the value of attribute format.
-
#named_tags ⇒ Object
Returns the value of attribute named_tags.
-
#processing ⇒ Object
Returns the value of attribute processing.
-
#quiet_assets ⇒ Object
Returns the value of attribute quiet_assets.
-
#rendered ⇒ Object
Returns the value of attribute rendered.
-
#semantic ⇒ Object
Returns the value of attribute semantic.
-
#started ⇒ Object
Returns the value of attribute started.
Instance Method Summary collapse
-
#initialize ⇒ Options
constructor
Setup default values.
Constructor Details
#initialize ⇒ Options
Setup default values
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/rails_semantic_logger/options.rb', line 116 def initialize @semantic = true @started = false @processing = false @rendered = false @ap_options = {multiline: false} @add_file_appender = true @quiet_assets = false @format = :default @named_tags = nil @filter = nil @console_logger = true @action_message_format = nil end |
Instance Attribute Details
#action_message_format ⇒ Object
Returns the value of attribute action_message_format.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def @action_message_format end |
#add_file_appender ⇒ Object
Returns the value of attribute add_file_appender.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def add_file_appender @add_file_appender end |
#ap_options ⇒ Object
Returns the value of attribute ap_options.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def @ap_options end |
#console_logger ⇒ Object
Returns the value of attribute console_logger.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def console_logger @console_logger end |
#filter ⇒ Object
Returns the value of attribute filter.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def filter @filter end |
#format ⇒ Object
Returns the value of attribute format.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def format @format end |
#named_tags ⇒ Object
Returns the value of attribute named_tags.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def @named_tags end |
#processing ⇒ Object
Returns the value of attribute processing.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def processing @processing end |
#quiet_assets ⇒ Object
Returns the value of attribute quiet_assets.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def quiet_assets @quiet_assets end |
#rendered ⇒ Object
Returns the value of attribute rendered.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def rendered @rendered end |
#semantic ⇒ Object
Returns the value of attribute semantic.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def semantic @semantic end |
#started ⇒ Object
Returns the value of attribute started.
112 113 114 |
# File 'lib/rails_semantic_logger/options.rb', line 112 def started @started end |