context_logger 0.0.38 → 0.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d88048609f3e0ed0cea729310728ae3c6f3b99d
4
- data.tar.gz: 3b3931d16d366b7e085978f64fd7b211b7e2ab62
3
+ metadata.gz: 4adde5696ccb1cee04e4f090b341a5cff7735e3d
4
+ data.tar.gz: a44ee6163026d37cfff05d27f51cabf999d8cdf7
5
5
  SHA512:
6
- metadata.gz: 8699a55324aa77985882ab6d14651d8d59d99d4c50fef9643a350a92c1817b111f4d0584a9b2d36617fb3de6b626e19fdfeca8f9708e4daabfc5184cffc465d3
7
- data.tar.gz: 2feed016c87f575b5d8fa14e7097f9b771c55a6e8030d4904e205de25da18fe11ea80f037d1c02dafe4c526eb8d9675e4dee020f1eae20b40d9e57a57bfa4808
6
+ metadata.gz: f373ef4c2339c1d340e331f595f57bbae7c0c64b0cf6f5ad076f870716808a9506a3f7b4506f05947127542fec5dcbb12900b3ec4f42749ff5e46b02151467e4
7
+ data.tar.gz: 2e338e74825a0a9b4465c0cdca911687bb2e51e06c67543544b85bfdece6f8a67e73ea28afeba7fff893709b7699e4138e4f2e55b74c34ad3b7246cbcca655fb
@@ -3,7 +3,7 @@ module Api
3
3
  module Resources
4
4
  class ContextLoggerController < ::ActionController::Base
5
5
  def index
6
- if(params[:action_id].nil?)
6
+ if params[:action_id].nil?
7
7
  render plain: 'Missing mandatory parameter action_id', :status => 400, layout: false
8
8
  return
9
9
  end
@@ -8,11 +8,11 @@ class CreateContextLogs < ActiveRecord::Migration
8
8
  t.string :server
9
9
  t.string :action_id
10
10
  t.string :method
11
- t.string :params
11
+ t.text :params
12
12
  t.text :message
13
13
  t.text :stack_trace
14
14
 
15
- t.timestamps
15
+ t.column :created_at, :datetime
16
16
  end
17
17
  end
18
18
  end
@@ -2,7 +2,8 @@ require 'context_logger/engine'
2
2
 
3
3
  module ContextLogger
4
4
 
5
- SEVERITY_TYPES = [:info, :warn, :error, :debug, :unknown, :fatal]
5
+ SEVERITY_TYPES = [:info, :warn, :error, :debug, :fatal, #:unknown
6
+ ]
6
7
 
7
8
  DEFAULTS = {
8
9
  context: :context_log,
@@ -10,26 +11,29 @@ module ContextLogger
10
11
  # server_name: nil,
11
12
  # method: nil,
12
13
  # params: nil,
13
- message: 'Empty message',
14
+ # message: 'Empty message',
14
15
  # stack_trace: nil
15
16
  }
16
17
 
17
- @options = {}.merge(DEFAULTS)
18
+ ALL_DESTINATIONS = {
19
+ write_rails_log: true,
20
+ write_context_log: true,
21
+ write_db_log: true
22
+ }
23
+
24
+ @options = DEFAULTS.clone
18
25
 
26
+ # build dynamically log methods for each of the SEVERITY_TYPES
19
27
  SEVERITY_TYPES.each do |severity_type|
20
28
  define_singleton_method severity_type do |message, method, params, stack_trace=nil, action_id=nil, context=nil ,server=nil|
21
29
  self.log({severity: severity_type, context: context, server: server, action_id: action_id, method: method, params: params, message: message, stack_trace: stack_trace})
22
30
  end
23
31
  end
24
32
 
33
+ # hash (caching) of loggers by context
25
34
  @context_loggers = {}
26
35
 
27
36
  @destinations = {}
28
- ALL_DESTINATIONS = {
29
- write_rails_log: true,
30
- write_context_log: true,
31
- write_db_log: true
32
- }
33
37
 
34
38
  def self.setup(options)
35
39
  @options = (@options || {}).merge(options)
@@ -45,7 +49,7 @@ module ContextLogger
45
49
  return
46
50
  end
47
51
 
48
- @destinations = _destinations.select{|k, _| ALL_DESTINATIONS[k]}
52
+ @destinations = _destinations.select{|k, v| ALL_DESTINATIONS[k] and v}
49
53
  end
50
54
 
51
55
  def self.destinations
@@ -67,8 +71,8 @@ module ContextLogger
67
71
  def self.log(params)
68
72
  params_with_defaults = options.merge(params.reject{|_, v| v.nil?})
69
73
 
70
- destinations.each do |log_destination, should_write_log|
71
- self.send(log_destination, params_with_defaults) if should_write_log
74
+ destinations.each do |log_destination, _|
75
+ self.send(log_destination, params_with_defaults)
72
76
  end
73
77
  end
74
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: context_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.38
4
+ version: 0.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Libster