Class: Logging::Appenders::GoogleCloudLogging
- Inherits:
-
Logging::Appender
- Object
- Logging::Appender
- Logging::Appenders::GoogleCloudLogging
- Includes:
- Buffering
- Defined in:
- lib/logging/appenders/gcl.rb
Constant Summary collapse
- SEVERITY_NAMES =
%w(DEBUG INFO NOTICE WARNING ERROR CRITICAL ALERT EMERGENCY)
Instance Attribute Summary collapse
-
#keyfile ⇒ Object
readonly
Returns the value of attribute keyfile.
-
#log_name ⇒ Object
readonly
Returns the value of attribute log_name.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#resource_labels ⇒ Object
readonly
Returns the value of attribute resource_labels.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
Instance Method Summary collapse
- #close(*args) ⇒ Object
- #flush ⇒ Object
- #gcloud_logging ⇒ Object
-
#initialize(name, options = {}) ⇒ GoogleCloudLogging
constructor
A new instance of GoogleCloudLogging.
- #resource ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ GoogleCloudLogging
Returns a new instance of GoogleCloudLogging.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/logging/appenders/gcl.rb', line 21 def initialize(name, ={}) super(name, ) auto_flushing = .fetch(:buffsize, .fetch(:buffer_size, 100)) configure_buffering({:auto_flushing => auto_flushing}.merge()) @project_id = .fetch(:project_id, nil) raise ArgumentError, 'Must specify project id' if @project_id.nil? @log_name = .fetch(:log_name, nil) raise ArgumentError, 'Must specify log name' if @log_name.nil? @resource_type = .fetch(:resource_type, nil) raise ArgumentError, 'Must specify resource type' if @resource_type.empty? @resource_labels = .fetch(:resource_labels, nil) @keyfile = .fetch(:keyfile, nil) end |
Instance Attribute Details
#keyfile ⇒ Object (readonly)
Returns the value of attribute keyfile.
19 20 21 |
# File 'lib/logging/appenders/gcl.rb', line 19 def keyfile @keyfile end |
#log_name ⇒ Object (readonly)
Returns the value of attribute log_name.
19 20 21 |
# File 'lib/logging/appenders/gcl.rb', line 19 def log_name @log_name end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
19 20 21 |
# File 'lib/logging/appenders/gcl.rb', line 19 def project_id @project_id end |
#resource_labels ⇒ Object (readonly)
Returns the value of attribute resource_labels.
19 20 21 |
# File 'lib/logging/appenders/gcl.rb', line 19 def resource_labels @resource_labels end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
19 20 21 |
# File 'lib/logging/appenders/gcl.rb', line 19 def resource_type @resource_type end |
Instance Method Details
#close(*args) ⇒ Object
47 48 49 |
# File 'lib/logging/appenders/gcl.rb', line 47 def close( *args ) super(false) end |
#flush ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/logging/appenders/gcl.rb', line 51 def flush return self if @buffer.empty? entries = nil sync do entries = @buffer.dup @buffer.clear end send_entries(entries) self end |
#gcloud_logging ⇒ Object
39 40 41 |
# File 'lib/logging/appenders/gcl.rb', line 39 def gcloud_logging @gcloud_logging ||= Gcloud.new(@project_id, @keyfile).logging end |
#resource ⇒ Object
43 44 45 |
# File 'lib/logging/appenders/gcl.rb', line 43 def resource gcloud_logging.resource(@resource_type, @resource_labels) end |