Class: Timber::Contexts::Runtime
- Inherits:
-
Timber::Context
- Object
- Timber::Context
- Timber::Contexts::Runtime
- Defined in:
- lib/timber/contexts/runtime.rb
Overview
The runtime context adds current runtime data to your logs, such as the file, line number, class or module name, etc. This makes it easy to tail and search your logs by their origin in your code. For example, if you are debugging a specific class, you can narrow by that class and see only it’s logs.
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#function ⇒ Object
readonly
Returns the value of attribute function.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#vm_pid ⇒ Object
readonly
Returns the value of attribute vm_pid.
Instance Method Summary collapse
-
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
-
#initialize(attributes) ⇒ Runtime
constructor
A new instance of Runtime.
Constructor Details
#initialize(attributes) ⇒ Runtime
Returns a new instance of Runtime.
14 15 16 17 18 19 20 21 22 |
# File 'lib/timber/contexts/runtime.rb', line 14 def initialize(attributes) @application = attributes[:application] @class_name = attributes[:class_name] @file = attributes[:file] @function = attributes[:function] @line = attributes[:line] @module_name = attributes[:module_name] @vm_pid = Timber::Util::Object.try(attributes[:vm_pid], :to_s) end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
12 13 14 |
# File 'lib/timber/contexts/runtime.rb', line 12 def application @application end |
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
12 13 14 |
# File 'lib/timber/contexts/runtime.rb', line 12 def class_name @class_name end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
12 13 14 |
# File 'lib/timber/contexts/runtime.rb', line 12 def file @file end |
#function ⇒ Object (readonly)
Returns the value of attribute function.
12 13 14 |
# File 'lib/timber/contexts/runtime.rb', line 12 def function @function end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
12 13 14 |
# File 'lib/timber/contexts/runtime.rb', line 12 def line @line end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
12 13 14 |
# File 'lib/timber/contexts/runtime.rb', line 12 def module_name @module_name end |
#vm_pid ⇒ Object (readonly)
Returns the value of attribute vm_pid.
12 13 14 |
# File 'lib/timber/contexts/runtime.rb', line 12 def vm_pid @vm_pid end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
25 26 27 28 |
# File 'lib/timber/contexts/runtime.rb', line 25 def as_json( = {}) {application: application, class_name: class_name, file: file, function: function, line: line, module_name: module_name, vm_pid: vm_pid} end |