wamp_client 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: 581eccd047b7af79793d5fa979acf389b3f9b6b3
4
- data.tar.gz: c08465e7c7ff8c4d631e8213af9f4bc940b35731
3
+ metadata.gz: 6af897a4b27192f6199baed427630045313a6ae2
4
+ data.tar.gz: ae516cf28afd0385d7f583eee30747eb3a29a532
5
5
  SHA512:
6
- metadata.gz: c24b0896d73a539ede06d8e369f9003bc3e3c5e3fe4b22d3e4726509aaea7ec7bff767718e6ea504fd07af0bc7b3e844448831feeb19480f1797dea6dd073840
7
- data.tar.gz: fea059c5cd3b4221b57dd0e3f90a7501c511cbf67168acfd9d3e467a8dd314c5604bfea33ea26fd211eb760ca3c61d65c65913160f7f69a71ab48ec6c398747b
6
+ metadata.gz: 32f33811288935d879e4eadf2ed00a1c83378835b9f71db6d4b7fada229876941e0b68b4e8b1adc59a3f1643b96aa6fe9ffc3d54a6f4a9798a73e7c9b8ebf7d5
7
+ data.tar.gz: f2b7adf5a18befc31bafa610202c9d20d6942c44303cffba027f0495798e52dd162a49669cd8fabbe366af7307b5e88c28ba44eff7cd3a661e95ff063cc21230
data/README.md CHANGED
@@ -13,6 +13,8 @@ execute in the background.
13
13
 
14
14
  ## Revision History
15
15
 
16
+ - v0.2.1:
17
+ - Logging cleanup
16
18
  - v0.2.0:
17
19
  - Breaking changes to the API including
18
20
  - Moving CallResult, CallError, CallDefer, and ProgressiveCallDefer to common module called "Response"
data/lib/wamp/client.rb CHANGED
@@ -5,7 +5,7 @@ require 'wamp/client/connection'
5
5
  require 'wamp/client/session'
6
6
  require 'wamp/client/auth'
7
7
  require 'wamp/client/response'
8
- require 'logger'
8
+ require 'wamp/client/logging'
9
9
 
10
10
  module Wamp
11
11
  module Client
@@ -13,31 +13,14 @@ module Wamp
13
13
  # Returns the logger object
14
14
  #
15
15
  def self.logger
16
- unless defined?(@logger)
17
- @logger = Logger.new(STDOUT)
18
- @logger.level = Logger::INFO
19
- end
20
- @logger
16
+ Logging.logger
21
17
  end
22
18
 
23
19
  # Sets the log level
24
20
  #
25
21
  # @param log_level [Symbol] - the desired log level
26
22
  def self.log_level=(log_level)
27
- level =
28
- case log_level
29
- when :error
30
- Logger::ERROR
31
- when :debug
32
- Logger::DEBUG
33
- when :fatal
34
- Logger::FATAL
35
- when :warn
36
- Logger::WARN
37
- else
38
- Logger::INFO
39
- end
40
- self.logger.level = level
23
+ Logging.log_level = log_level
41
24
  end
42
25
 
43
26
  end
@@ -0,0 +1,46 @@
1
+ require 'logger'
2
+
3
+ module Wamp
4
+ module Client
5
+ module Logging
6
+
7
+ LOG_LEVEL_LOOKUP = {
8
+ error: Logger::ERROR,
9
+ debug: Logger::DEBUG,
10
+ info: Logger::INFO,
11
+ warn: Logger::WARN,
12
+ }
13
+
14
+ class Pretty < Logger::Formatter
15
+ def call(severity, time, program_name, message)
16
+ "#{time.utc.iso8601(3)} #{::Process.pid} #{severity[0]}: #{message}\n"
17
+ end
18
+ end
19
+
20
+ class WithoutTimestamp < Pretty
21
+ def call(severity, time, program_name, message)
22
+ "#{::Process.pid} #{severity[0]}: #{message}\n"
23
+ end
24
+ end
25
+
26
+ # Returns the logger object
27
+ #
28
+ def self.logger
29
+ unless defined?(@logger)
30
+ $stdout.sync = true unless ENV['RAILS_ENV'] == "production"
31
+ @logger = Logger.new $stdout
32
+ @logger.level = Logger::INFO
33
+ @logger.formatter = ENV['DYNO'] ? WithoutTimestamp.new : Pretty.new
34
+ end
35
+ @logger
36
+ end
37
+
38
+ # Sets the log level
39
+ #
40
+ # @param log_level [Symbol] - the desired log level
41
+ def self.log_level=(log_level)
42
+ self.logger.level = LOG_LEVEL_LOOKUP[log_level.to_sym] || :info
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,5 @@
1
1
  module Wamp
2
2
  module Client
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wamp_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Chapman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-10 00:00:00.000000000 Z
11
+ date: 2018-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -155,6 +155,7 @@ files:
155
155
  - lib/wamp/client/check.rb
156
156
  - lib/wamp/client/connection.rb
157
157
  - lib/wamp/client/event.rb
158
+ - lib/wamp/client/logging.rb
158
159
  - lib/wamp/client/manager/base.rb
159
160
  - lib/wamp/client/manager/base_multiple.rb
160
161
  - lib/wamp/client/manager/establish.rb