jobly 0.2.2 → 0.2.3

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: bbc38c3493fa50569ff1b574727a9d854d9c64694d8d7d1ece218ee0e78dd6c4
4
- data.tar.gz: 518ad55187220df99d35d18b1a9cf9f7e22b0a7eb0455f36dc23c4202b9b7bfa
3
+ metadata.gz: 8ee66973f52902d8ddc90c2b2d6547d05b8dcef25f3639754ce3fb41006b618e
4
+ data.tar.gz: 07b1a0d259b813db4e7f5ccd36e9f5759ed97c9460f05e49a2a726216a5ed8c2
5
5
  SHA512:
6
- metadata.gz: e2de8768494317847f01b52519bb2cfc374e30e885ba5a1ffa3cf801c5f966c63c2c1c1dbfe74f0a0e1f4614a14051ce86efbd8e8fead41bf44371a2f12b81bd
7
- data.tar.gz: 9ae8b72be0ae7c4f79ed0616e990d9a58031c16bbe6d19db8236a7f600854fe6f605bcfdd46c1d292f753258c398e7f0bc3a608ea28ee9fe672d10b3dfe3a095
6
+ metadata.gz: 0dcbb539e7cafc9ebf44d58b8fe07e8df36d8e4209f431f26051e6db780c79df98ec3b099f66439597d84b0b3a987bcd33670c5f5962afe33545d615ca1ad461
7
+ data.tar.gz: 44a0d0305abd84288abef22a631cce2927f0df1b2daefa494da0192a6476deaaf35e338019a2d7a7e97fe48f0f806e4dff65f17bf8764abf89cb271d99499f83
@@ -11,7 +11,7 @@ module Jobly
11
11
 
12
12
  configure :development, :production do
13
13
  set :server, :puma
14
- set :logger, Jobly.logger if Jobly.logger
14
+ set :logger, Log.new(Jobly.log, :sinatra) if Jobly.log
15
15
  end
16
16
 
17
17
  configure :development do
@@ -6,6 +6,7 @@ module Jobly
6
6
  include JobExtensions::Actions
7
7
  include JobExtensions::Solo
8
8
  using KeywordArgs
9
+ using ToSlug
9
10
 
10
11
  sidekiq_options retry: 5, backtrace: 5
11
12
  attr_reader :params
@@ -43,6 +44,18 @@ module Jobly
43
44
  raise NotImplementedError
44
45
  end
45
46
 
47
+ def logger
48
+ @logger ||= logger!
49
+ end
50
+
51
+ def logger!
52
+ if !Jobly.log or !Jobly.log.include? "%s"
53
+ Sidekiq.logger
54
+ else
55
+ Log.new Jobly.log, self.class.name.to_slug
56
+ end
57
+ end
58
+
46
59
  private
47
60
 
48
61
  def run_before_filter
@@ -3,15 +3,23 @@ require 'uri'
3
3
 
4
4
  module Jobly
5
5
  module Log
6
- def self.new(target = nil)
6
+ def self.new(target = nil, tag = nil)
7
7
  if !target or target.to_sym == :stdout or target == STDOUT
8
8
  return Logger.new STDOUT
9
9
  end
10
10
 
11
- unless target.start_with? 'syslog://'
12
- return Logger.new target
11
+ target %= tag if tag and target.include? "%s"
12
+
13
+ if target.start_with? 'syslog://'
14
+ remote_syslog_logger target
15
+ else
16
+ Logger.new target
13
17
  end
18
+ end
19
+
20
+ private
14
21
 
22
+ def self.remote_syslog_logger(target)
15
23
  uri = URI target
16
24
  RemoteSyslogLogger.new (uri.host || 'localhost'), (uri.port || 514),
17
25
  local_hostname: uri.user, program: uri.password
@@ -47,7 +47,7 @@ module Jobly
47
47
 
48
48
  def self.logger
49
49
  return nil unless log
50
- @logger ||= Log.new log
50
+ @logger ||= Log.new log, :jobly
51
51
  end
52
52
 
53
53
  def self.log=(target)
@@ -0,0 +1,9 @@
1
+ module Jobly
2
+ module ToSlug
3
+ refine String do
4
+ def to_slug
5
+ downcase.gsub(/[^\w]/, ' ').strip.squeeze(' ').tr(' ', '-')
6
+ end
7
+ end
8
+ end
9
+ end
@@ -20,7 +20,7 @@ module Jobly
20
20
  # :nocov:
21
21
  end
22
22
 
23
- Sidekiq::Logging.logger = Jobly.logger if Jobly.logger
23
+ Sidekiq::Logging.logger = Log.new(Jobly.log, :sidekiq) if Jobly.log
24
24
  end
25
25
  end
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module Jobly
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-16 00:00:00.000000000 Z
11
+ date: 2019-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mister_bin
@@ -210,6 +210,7 @@ files:
210
210
  - lib/jobly/refinements/argument_converters.rb
211
211
  - lib/jobly/refinements/convert_to_typed.rb
212
212
  - lib/jobly/refinements/keyword_args.rb
213
+ - lib/jobly/refinements/to_slug.rb
213
214
  - lib/jobly/server.rb
214
215
  - lib/jobly/sidekiq.rb
215
216
  - lib/jobly/version.rb