mn_utils_gem 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2d6a173168ff1fcb42ff9ba894f5420b9c59e6e2040a388bed49b9a7ac0aff7
4
- data.tar.gz: ddd38e58f9dcb69ae9eb79774910765c3a3e5204b382b964489eb838a26d0386
3
+ metadata.gz: 70ae8ad27e749906b14ea11635f92fb244ced2c217b1822324451a825d765545
4
+ data.tar.gz: 5154105cc37031f73afe04ecb954c244f524c79279c2e29ddf60c1fd23e68cd9
5
5
  SHA512:
6
- metadata.gz: f535bb375ad88b13c41fd5d4f0f5c13657df7b7151235cd8d9988b0521336bee10ebb5f6ae96f9f66c90170fcdd7b15620c9c8d58acc4dc8dfd92a7c65551e94
7
- data.tar.gz: 62e823d206985190d0899b9288bb950c4063cf8b85fefbc46b35ea903bdb6752b533a67c48302c41aa3e6d38ce6c1aa988f7be833b092e0fad830279bb7ca6d3
6
+ metadata.gz: 6b93c8badd0cb3c373be3418645654a43a641a2d6af90d550b8edca06ab65538b355c2f610f983e648edad43f6f41430c9a91589b7293d75d2d172892b92f54d
7
+ data.tar.gz: 593601ff2eccbf62105eb83418bdc1628987213e5b89484ef840a64895cd7a4b458044a1ff40906846a349bcdc6e542810f71ebc8f8df52f8cfd73b39a9c98f3
@@ -53,7 +53,7 @@ module MnUtils
53
53
 
54
54
  # this creates a reverse map of all site actions and their corresponding group
55
55
  # for quick lookups by the code
56
- @_site_action_group_map = Hash[*(@_site_actions_and_groups.map {|k,v| v.map {|x| [x, k]}}.flatten)].freeze
56
+ @_site_action_group_map = Hash[*(@_site_actions_and_groups.map {|k, v| v.map {|x| [x, k]}}.flatten)].freeze
57
57
  end
58
58
 
59
59
  def log(message, site_action, payload = {})
@@ -103,42 +103,43 @@ module MnUtils
103
103
  send_to_graylog full_payload
104
104
  send_to_cloudwatch full_payload
105
105
  end
106
- end
107
106
 
108
- private
107
+ private
109
108
 
110
- def send_to_graylog(payload)
111
- if ENV.key?('GRAYLOG_GELF_UDP_HOST') && ENV.key?('GRAYLOG_GELF_UDP_PORT')
112
- n = GELF::Notifier.new(ENV['GRAYLOG_GELF_UDP_HOST'], ENV['GRAYLOG_GELF_UDP_PORT'])
113
- n.notify! payload
114
- else
115
- Rails.logger.debug("Payload for Graylog: #{payload}")
109
+ def send_to_graylog(payload)
110
+ if ENV.key?('GRAYLOG_GELF_UDP_HOST') && ENV.key?('GRAYLOG_GELF_UDP_PORT')
111
+ n = GELF::Notifier.new(ENV['GRAYLOG_GELF_UDP_HOST'], ENV['GRAYLOG_GELF_UDP_PORT'])
112
+ n.notify! payload
113
+ else
114
+ Rails.logger.debug("Payload for Graylog: #{payload}")
115
+ end
116
+ rescue Exception => e
117
+ Rails.logger.error e
116
118
  end
117
- rescue Exception => e
118
- Rails.logger.error e
119
- end
120
-
121
- def send_to_cloudwatch(payload)
122
- metric_name = payload[:_site_action]
123
- metric_data = [{
124
- metric_name: metric_name,
125
- value: 1,
126
- unit: "Count"
127
- }]
128
- if ENV.key?'CLOUDWATCH_ROOT_NAMESPACE'
129
- root_namespace = ENV['CLOUDWATCH_ROOT_NAMESPACE']
130
- second_namespace = payload[:_site_action_group]
131
- namespace = "#{root_namespace}/#{second_namespace}"
132
- cw = Aws::CloudWatch::Client.new
133
- cw.put_metric_data({
134
- namespace: namespace,
135
- metric_data: metric_data
136
- })
137
- else
138
- Rails.logger.debug("Payload for Cloudwatch: #{metric_data}")
119
+
120
+ def send_to_cloudwatch(payload)
121
+ metric_name = payload[:_site_action]
122
+ metric_data = [{
123
+ metric_name: metric_name,
124
+ value: 1,
125
+ unit: "Count"
126
+ }]
127
+ if ENV.key? 'CLOUDWATCH_ROOT_NAMESPACE'
128
+ root_namespace = ENV['CLOUDWATCH_ROOT_NAMESPACE']
129
+ second_namespace = payload[:_site_action_group]
130
+ namespace = "#{root_namespace}/#{second_namespace}"
131
+ cw = Aws::CloudWatch::Client.new
132
+ cw.put_metric_data({
133
+ namespace: namespace,
134
+ metric_data: metric_data
135
+ })
136
+ else
137
+ Rails.logger.debug("Payload for Cloudwatch: #{metric_data}")
138
+ end
139
+ rescue Exception => e
140
+ Rails.logger.error e
139
141
  end
140
- rescue Exception => e
141
- Rails.logger.error e
142
- end
143
142
 
144
- end
143
+ end # of class SiteAction
144
+
145
+ end # of module MnUtils
@@ -1,3 +1,3 @@
1
1
  module MnUtilsGem
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mn_utils_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shamim Mirzai