Module: Errlog
- Extended by:
- Constants
- Includes:
- Constants
- Defined in:
- lib/errlog.rb,
lib/errlog/context.rb,
lib/errlog/version.rb,
lib/errlog/packager.rb,
lib/errlog/constants.rb,
lib/errlog/chain_loggger.rb,
lib/errlog/rails_controller_extensions.rb
Overview
The reporting module for errlog service, see errorlog.com for details.
The usage is quite simple:
Errlog.configure(
account_id, account_secret,
:application => 'MyGreatApplication')
And use any of {Errlog.context} and {Errlog::Context} methods to report exceptions,
collect logs, traces and so on.
See http://errorlog.co/help for more.
Defined Under Namespace
Modules: Constants, ControllerFilter
Classes: ChainLogger, Context, ContextMiddleware, Packager, Railtie
Constant Summary
collapse
- VERSION =
"0.3.7"
- @@configured =
false
Constants included
from Constants
Constants::ERROR, Constants::NOT_FOUND, Constants::STAT_DATA, Constants::TRACE, Constants::WARNING
Class Method Summary
collapse
-
.application ⇒ Object
-
.clear_context ⇒ Object
-
.configure(id, key, opts = {}) ⇒ Object
-
.configured? ⇒ Boolean
-
.context ⇒ Object
-
.default_platform ⇒ Object
-
.error(text, details = nil, severity = Errlog::TRACE, &block) ⇒ Object
-
.exception(e, &block) ⇒ Object
-
.logger(logger = nil) ⇒ ChainLogger
-
.pack(data) ⇒ Object
-
.packager(id, key) ⇒ Errlog::Packager
Packager instance for configured credentials, see Errorlog.configure.
-
.protect(component_name = nil, options = {}, &block) ⇒ Object
-
.protect_rethrow(component_name = nil, &block) ⇒ Object
-
.rails? ⇒ Boolean
-
.rails_test? ⇒ Boolean
-
.report(text, severity = Errlog::ERROR, &block) ⇒ Object
-
.trace(text, details = nil, severity = Errlog::TRACE, &block) ⇒ Object
-
.use_logging? ⇒ Boolean
-
.warning(text, details = nil, severity = Errlog::TRACE, &block) ⇒ Object
Methods included from Constants
is_error?, is_trace?, is_warning?, severity_name
Class Method Details
.application ⇒ Object
93
94
95
|
# File 'lib/errlog.rb', line 93
def self.application
@@application
end
|
.clear_context ⇒ Object
149
150
151
152
153
|
# File 'lib/errlog.rb', line 149
def self.clear_context
ctx = Errlog::Context.new
Thread.current[:errlog_context] = ctx
ctx
end
|
Configure your instance. Sbhould be called before any other methods. Follow errorlog.co/help/rails to get your credentials
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/errlog.rb', line 49
def self.configure id, key, opts={}
@@configured = true
@@app_id, @@app_secret, @options = id, key, opts
@@application = opts[:application] || ''
@@packager = packager @@app_id, @@app_secret
@@host = opts[:host] || "http://errorlog.co"
@@client = HTTPClient.new
@@opts = opts
@@rails = defined?(Rails)
@@loggers_ready = false
@@component = nil
if @@rails && !opts[:no_catch_logs]
if Rails.env != 'test'
@@logger = Rails.logger = ChainLogger.new Rails.logger
ActionController::Base.logger = ChainLogger.new ActionController::Base.logger
if defined?(ActiveRecord)
ActiveRecord::Base.logger = ChainLogger.new ActiveRecord::Base.logger
end
end
@@loggers_ready = true
if defined?(Delayed)
require 'errlog/dj'
end
end
end
|
97
98
99
100
101
102
103
|
# File 'lib/errlog.rb', line 97
def self.configured?
if @@configured
(@@rails && Rails.env == 'test') || defined?(@@app_id) && @@app_id && @@app_secret
else
false
end
end
|
.context ⇒ Object
155
156
157
|
# File 'lib/errlog.rb', line 155
def self.context
Thread.current[:errlog_context] || clear_context
end
|
105
106
107
|
# File 'lib/errlog.rb', line 105
def self.default_platform
@@rails ? 'rails' : 'ruby'
end
|
.error(text, details = nil, severity = Errlog::TRACE, &block) ⇒ Object
137
138
139
|
# File 'lib/errlog.rb', line 137
def self.error text, details=nil, severity=Errlog::TRACE, &block
self.context.error text, details, severity, &block
end
|
.exception(e, &block) ⇒ Object
129
130
131
|
# File 'lib/errlog.rb', line 129
def self.exception e, &block
self.context.exception e, &block
end
|
.logger(logger = nil) ⇒ ChainLogger
Create logger that will report its content on error, trace and warning and ErrlogContext reporting funtions. It can user existing logger to pass through, ot will create Logger with STDOUT
84
85
86
87
|
# File 'lib/errlog.rb', line 84
def self.logger logger = nil
logger ||= Logger.new(STDOUT)
@@logger ||= ChainLogger.new logger
end
|
.pack(data) ⇒ Object
117
118
119
|
# File 'lib/errlog.rb', line 117
def self.pack data
@@packager.pack(data)
end
|
Returns packager instance for configured credentials, see Errorlog.configure.
39
40
41
|
# File 'lib/errlog.rb', line 39
def self.packager id, key
return Packager.new id, key
end
|
.protect(component_name = nil, options = {}, &block) ⇒ Object
121
122
123
|
# File 'lib/errlog.rb', line 121
def self.protect component_name=nil, options={}, &block
context.protect component_name, options, &block
end
|
.protect_rethrow(component_name = nil, &block) ⇒ Object
125
126
127
|
# File 'lib/errlog.rb', line 125
def self.protect_rethrow component_name=nil, &block
context.protect_rethrow component_name, &block
end
|
.rails? ⇒ Boolean
109
110
111
|
# File 'lib/errlog.rb', line 109
def self.rails?
@@rails
end
|
.rails_test? ⇒ Boolean
113
114
115
|
# File 'lib/errlog.rb', line 113
def self.rails_test?
@rails_test == nil and @rails_test = @@rails && Rails.env == 'test'
end
|
.report(text, severity = Errlog::ERROR, &block) ⇒ Object
145
146
147
|
# File 'lib/errlog.rb', line 145
def self.report text, severity = Errlog::ERROR, &block
self.context.report text, severity, &block
end
|
.trace(text, details = nil, severity = Errlog::TRACE, &block) ⇒ Object
133
134
135
|
# File 'lib/errlog.rb', line 133
def self.trace text, details=nil, severity=Errlog::TRACE, &block
self.context.trace text, details, severity, &block
end
|
.use_logging? ⇒ Boolean
89
90
91
|
# File 'lib/errlog.rb', line 89
def self.use_logging?
!@@opts[:no_logs]
end
|
.warning(text, details = nil, severity = Errlog::TRACE, &block) ⇒ Object
141
142
143
|
# File 'lib/errlog.rb', line 141
def self.warning text, details=nil, severity=Errlog::TRACE, &block
self.context.warning text, details, severity, &block
end
|