Class: Timber::Config
- Inherits:
-
Object
- Object
- Timber::Config
- Includes:
- Singleton
- Defined in:
- lib/timber/config.rb
Overview
Interface for setting and reading Timber configuration.
For Rails apps this is installed into config.timber. See examples below.
Defined Under Namespace
Classes: NoLoggerError
Constant Summary collapse
- PRODUCTION_NAME =
"production".freeze
- STAGING_NAME =
"staging".freeze
Instance Attribute Summary collapse
-
#append_metadata ⇒ Object
writeonly
Sets the attribute append_metadata.
-
#debug_logger ⇒ Object
Set a debug_logger to view internal Timber library log message.
-
#http_body_limit ⇒ Object
Truncates captured HTTP bodies to this specified limit.
-
#logger ⇒ Object
This is the logger Timber writes to.
Instance Method Summary collapse
-
#append_metadata? ⇒ Boolean
Should the logger append the Timber metadata.
-
#environment ⇒ Object
The environment your app is running in.
Instance Attribute Details
#append_metadata=(value) ⇒ Object (writeonly)
Sets the attribute append_metadata
21 22 23 |
# File 'lib/timber/config.rb', line 21 def (value) @append_metadata = value end |
#debug_logger ⇒ Object
Set a debug_logger to view internal Timber library log message. Useful for debugging. Defaults to nil. If set, debug messages will be written to this logger.
46 47 48 |
# File 'lib/timber/config.rb', line 46 def debug_logger @debug_logger end |
#http_body_limit ⇒ Object
Truncates captured HTTP bodies to this specified limit. The default is 2000. If you want to capture more data, you can raise this to a maximum of 5000, or lower this to be more efficient with data.
58 59 60 |
# File 'lib/timber/config.rb', line 58 def http_body_limit @http_body_limit end |
#logger ⇒ Object
This is the logger Timber writes to. All of the Timber integrations write to this logger. It should be set to your global logger to keep the logging destination consitent.
For Rails this is set automatically to Rails.logger.
90 91 92 |
# File 'lib/timber/config.rb', line 90 def logger @logger || Logger.new(STDOUT) end |
Instance Method Details
#append_metadata? ⇒ Boolean
Should the logger append the Timber metadata. This is automatically turned on for production and staging environments. Other environments should be set manually. If set to true log messages will look like:
log message @metadata {...}
72 73 74 75 76 77 78 |
# File 'lib/timber/config.rb', line 72 def if defined?(@append_metadata) return @append_metadata == true end production? || staging? end |
#environment ⇒ Object
The environment your app is running in. Defaults to RACK_ENV and RAILS_ENV.
34 35 36 |
# File 'lib/timber/config.rb', line 34 def environment @environment ||= ENV["RACK_ENV"] || ENV["RAILS_ENV"] || "development" end |