Class: ZgcpToolkit::Logger::GoogleCloudLogging
- Inherits:
-
Object
- Object
- ZgcpToolkit::Logger::GoogleCloudLogging
- Defined in:
- lib/zgcp_toolkit/logger/google_cloud_logging.rb
Instance Attribute Summary collapse
-
#log_name ⇒ Object
readonly
Returns the value of attribute log_name.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Class Method Summary collapse
Instance Method Summary collapse
- #flush! ⇒ Object
-
#initialize(log_name) ⇒ GoogleCloudLogging
constructor
A new instance of GoogleCloudLogging.
Constructor Details
#initialize(log_name) ⇒ GoogleCloudLogging
Returns a new instance of GoogleCloudLogging.
27 28 29 30 |
# File 'lib/zgcp_toolkit/logger/google_cloud_logging.rb', line 27 def initialize(log_name) @log_name = log_name.to_s @logger = self.class.client.logger(@log_name, self.class.resource) end |
Instance Attribute Details
#log_name ⇒ Object (readonly)
Returns the value of attribute log_name.
23 24 25 |
# File 'lib/zgcp_toolkit/logger/google_cloud_logging.rb', line 23 def log_name @log_name end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
23 24 25 |
# File 'lib/zgcp_toolkit/logger/google_cloud_logging.rb', line 23 def logger @logger end |
Class Method Details
.client ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/zgcp_toolkit/logger/google_cloud_logging.rb', line 10 def client @mutex.synchronize do @client = nil if @client_pid != Process.pid @client_pid = Process.pid @client ||= Google::Cloud::Logging.new end end |
.resource ⇒ Object
18 19 20 |
# File 'lib/zgcp_toolkit/logger/google_cloud_logging.rb', line 18 def resource @mutex.synchronize { @resource ||= Google::Cloud::Logging::Middleware.build_monitored_resource } end |
Instance Method Details
#flush! ⇒ Object
32 33 34 |
# File 'lib/zgcp_toolkit/logger/google_cloud_logging.rb', line 32 def flush! logger.writer.flush end |