Class: GoogleCloudRun::Logger
- Inherits:
-
Object
- Object
- GoogleCloudRun::Logger
show all
- Includes:
- Logger::Severity
- Defined in:
- lib/google_cloud_run/logger.rb
Constant Summary
Logger::Severity::G_ALERT, Logger::Severity::G_CRITICAL, Logger::Severity::G_DEBUG, Logger::Severity::G_DEFAULT, Logger::Severity::G_EMERGENCY, Logger::Severity::G_ERROR, Logger::Severity::G_INFO, Logger::Severity::G_NOTICE, Logger::Severity::G_WARNING
Instance Method Summary
collapse
-
#<<(msg) ⇒ Object
-
#alert(msg = nil, **labels, &block) ⇒ Object
-
#alert! ⇒ Object
-
#alert? ⇒ Boolean
-
#close ⇒ Object
implement ::Logger interface, but do nothing.
-
#critical(msg = nil, **labels, &block) ⇒ Object
(also: #fatal)
-
#critical! ⇒ Object
(also: #fatal!)
-
#critical? ⇒ Boolean
(also: #fatal?)
-
#datetime_format ⇒ Object
-
#datetime_format=(format) ⇒ Object
-
#debug(msg = nil, **labels, &block) ⇒ Object
-
#debug! ⇒ Object
-
#debug? ⇒ Boolean
-
#default(msg = nil, **labels, &block) ⇒ Object
(also: #unknown)
-
#default! ⇒ Object
-
#default? ⇒ Boolean
-
#emergency(msg = nil, **labels, &block) ⇒ Object
-
#emergency! ⇒ Object
-
#emergency? ⇒ Boolean
-
#error(msg = nil, **labels, &block) ⇒ Object
-
#error! ⇒ Object
-
#error? ⇒ Boolean
-
#flush ⇒ Object
called by ActiveSupport::LogSubscriber.flush_all!.
-
#formatter ⇒ Object
-
#formatter=(formatter) ⇒ Object
-
#info(msg = nil, **labels, &block) ⇒ Object
-
#info! ⇒ Object
-
#info? ⇒ Boolean
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
-
#inject_request(request) ⇒ Object
called by LoggerMiddleware.
-
#level=(level) ⇒ Object
(also: #sev_threshold)
-
#level?(level) ⇒ Boolean
-
#log(severity, msg = nil, progname = nil, **labels, &block) ⇒ Object
(also: #add)
-
#notice(msg = nil, **labels, &block) ⇒ Object
-
#notice! ⇒ Object
-
#notice? ⇒ Boolean
-
#reopen(logdev = nil) ⇒ Object
-
#warning(msg = nil, **labels, &block) ⇒ Object
(also: #warn)
-
#warning! ⇒ Object
(also: #warn!)
-
#warning? ⇒ Boolean
(also: #warn?)
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
Instance Method Details
#<<(msg) ⇒ Object
133
134
135
|
# File 'lib/google_cloud_run/logger.rb', line 133
def <<(msg)
log(G_DEBUG, msg)
end
|
#alert(msg = nil, **labels, &block) ⇒ Object
109
110
111
|
# File 'lib/google_cloud_run/logger.rb', line 109
def alert(msg = nil, **labels, &block)
write(G_ALERT, msg, labels, &block)
end
|
#alert! ⇒ Object
117
118
119
|
# File 'lib/google_cloud_run/logger.rb', line 117
def alert!
self.level = G_ALERT
end
|
#alert? ⇒ Boolean
113
114
115
|
# File 'lib/google_cloud_run/logger.rb', line 113
def alert?
self.level?(G_ALERT)
end
|
#close ⇒ Object
implement ::Logger interface, but do nothing
157
|
# File 'lib/google_cloud_run/logger.rb', line 157
def close; end
|
#critical(msg = nil, **labels, &block) ⇒ Object
Also known as:
fatal
97
98
99
|
# File 'lib/google_cloud_run/logger.rb', line 97
def critical(msg = nil, **labels, &block)
write(G_CRITICAL, msg, labels, &block)
end
|
#critical! ⇒ Object
Also known as:
fatal!
105
106
107
|
# File 'lib/google_cloud_run/logger.rb', line 105
def critical!
self.level = G_CRITICAL
end
|
#critical? ⇒ Boolean
Also known as:
fatal?
101
102
103
|
# File 'lib/google_cloud_run/logger.rb', line 101
def critical?
self.level?(G_CRITICAL)
end
|
148
149
150
|
# File 'lib/google_cloud_run/logger.rb', line 148
def datetime_format
"%FT%T.%9NZ" end
|
161
|
# File 'lib/google_cloud_run/logger.rb', line 161
def datetime_format=(format); end
|
#debug(msg = nil, **labels, &block) ⇒ Object
37
38
39
|
# File 'lib/google_cloud_run/logger.rb', line 37
def debug(msg = nil, **labels, &block)
write(G_DEBUG, msg, labels, &block)
end
|
#debug! ⇒ Object
45
46
47
|
# File 'lib/google_cloud_run/logger.rb', line 45
def debug!
self.level = G_DEBUG
end
|
#debug? ⇒ Boolean
41
42
43
|
# File 'lib/google_cloud_run/logger.rb', line 41
def debug?
self.level?(G_DEBUG)
end
|
#default(msg = nil, **labels, &block) ⇒ Object
Also known as:
unknown
25
26
27
|
# File 'lib/google_cloud_run/logger.rb', line 25
def default(msg = nil, **labels, &block)
write(G_DEFAULT, msg, labels, &block)
end
|
#default! ⇒ Object
33
34
35
|
# File 'lib/google_cloud_run/logger.rb', line 33
def default!
self.level = G_DEFAULT
end
|
#default? ⇒ Boolean
29
30
31
|
# File 'lib/google_cloud_run/logger.rb', line 29
def default?
self.level?(G_DEFAULT)
end
|
#emergency(msg = nil, **labels, &block) ⇒ Object
121
122
123
|
# File 'lib/google_cloud_run/logger.rb', line 121
def emergency(msg = nil, **labels, &block)
write(G_EMERGENCY, msg, labels, &block)
end
|
#emergency! ⇒ Object
129
130
131
|
# File 'lib/google_cloud_run/logger.rb', line 129
def emergency!
self.level = G_EMERGENCY
end
|
#emergency? ⇒ Boolean
125
126
127
|
# File 'lib/google_cloud_run/logger.rb', line 125
def emergency?
self.level?(G_EMERGENCY)
end
|
#error(msg = nil, **labels, &block) ⇒ Object
85
86
87
|
# File 'lib/google_cloud_run/logger.rb', line 85
def error(msg = nil, **labels, &block)
write(G_ERROR, msg, labels, &block)
end
|
#error! ⇒ Object
93
94
95
|
# File 'lib/google_cloud_run/logger.rb', line 93
def error!
self.level = G_ERROR
end
|
#error? ⇒ Boolean
89
90
91
|
# File 'lib/google_cloud_run/logger.rb', line 89
def error?
self.level?(G_ERROR)
end
|
#flush ⇒ Object
called by ActiveSupport::LogSubscriber.flush_all!
143
144
145
146
|
# File 'lib/google_cloud_run/logger.rb', line 143
def flush
Thread.current[thread_key] = nil
@out.flush
end
|
152
153
154
|
# File 'lib/google_cloud_run/logger.rb', line 152
def formatter
@formatter
end
|
163
|
# File 'lib/google_cloud_run/logger.rb', line 163
def formatter=(formatter); end
|
#info(msg = nil, **labels, &block) ⇒ Object
49
50
51
|
# File 'lib/google_cloud_run/logger.rb', line 49
def info(msg = nil, **labels, &block)
write(G_INFO, msg, labels, &block)
end
|
#info! ⇒ Object
57
58
59
|
# File 'lib/google_cloud_run/logger.rb', line 57
def info!
self.level = G_INFO
end
|
#info? ⇒ Boolean
53
54
55
|
# File 'lib/google_cloud_run/logger.rb', line 53
def info?
self.level?(G_INFO)
end
|
#inject_request(request) ⇒ Object
called by LoggerMiddleware
138
139
140
|
# File 'lib/google_cloud_run/logger.rb', line 138
def inject_request(request)
Thread.current[thread_key] = request
end
|
#level=(level) ⇒ Object
Also known as:
sev_threshold
12
13
14
|
# File 'lib/google_cloud_run/logger.rb', line 12
def level=(level)
@level = Severity.mapping(level)
end
|
#level?(level) ⇒ Boolean
16
17
18
|
# File 'lib/google_cloud_run/logger.rb', line 16
def level?(level)
Severity.mapping(level) >= @level
end
|
#log(severity, msg = nil, progname = nil, **labels, &block) ⇒ Object
Also known as:
add
20
21
22
23
|
# File 'lib/google_cloud_run/logger.rb', line 20
def log(severity, msg = nil, progname = nil, **labels, &block)
labels["progname"] = progname unless progname.blank?
write(severity, msg, labels, &block)
end
|
#notice(msg = nil, **labels, &block) ⇒ Object
61
62
63
|
# File 'lib/google_cloud_run/logger.rb', line 61
def notice(msg = nil, **labels, &block)
write(G_NOTICE, msg, labels, &block)
end
|
#notice! ⇒ Object
69
70
71
|
# File 'lib/google_cloud_run/logger.rb', line 69
def notice!
self.level = G_NOTICE
end
|
#notice? ⇒ Boolean
65
66
67
|
# File 'lib/google_cloud_run/logger.rb', line 65
def notice?
self.level?(G_NOTICE)
end
|
#reopen(logdev = nil) ⇒ Object
159
|
# File 'lib/google_cloud_run/logger.rb', line 159
def reopen(logdev = nil); end
|
#warning(msg = nil, **labels, &block) ⇒ Object
Also known as:
warn
73
74
75
|
# File 'lib/google_cloud_run/logger.rb', line 73
def warning(msg = nil, **labels, &block)
write(G_WARNING, msg, labels, &block)
end
|
#warning! ⇒ Object
Also known as:
warn!
81
82
83
|
# File 'lib/google_cloud_run/logger.rb', line 81
def warning!
self.level = G_WARNING
end
|
#warning? ⇒ Boolean
Also known as:
warn?
77
78
79
|
# File 'lib/google_cloud_run/logger.rb', line 77
def warning?
self.level?(G_WARNING)
end
|