globalog 0.1.3 → 0.1.4

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.
@@ -62,6 +62,7 @@ require 'logger'
62
62
  class GlobaLog < Logger
63
63
  require File.join( File.dirname( File.expand_path(__FILE__)), 'globalog_args')
64
64
  require File.join( File.dirname( File.expand_path(__FILE__)), 'globalog_hijack')
65
+ require File.join( File.dirname( File.expand_path(__FILE__)), 'globalog_runsync')
65
66
 
66
67
  # The GlobaLog.logger acts as a constructor method for the logger.
67
68
  # === Parameters
@@ -7,8 +7,8 @@ class GlobaLog
7
7
  module Args
8
8
 
9
9
  def Args.are(args,override=false)
10
- $logger_args ||= Hash.new
11
- if override == true
10
+ $logger_args ||= Hash.new; $logger_args[:opts] = true unless args[:opts].nil?
11
+ if $logger_args[:opts].nil? and override == true
12
12
  $logger_args[:log_level] = args[:log_level].to_sym unless args[:log_level].nil?
13
13
  $logger_args[:log_output] = args[:log_output] unless args[:log_output].nil?
14
14
  $logger_args[:log_opts] = args[:log_opts] unless args[:log_opts].nil?
@@ -10,17 +10,21 @@ class GlobaLog
10
10
 
11
11
  def initialize
12
12
  super()
13
- self[:log_level] = nil
14
- self[:log_output] = nil
15
- opts = OptionParser.new do |opts|
16
- opts.on('-L','--log-level [STRING]','sets the Test Log Level') do |string|
17
- self[:log_level] = string.to_sym
18
- end
19
- opts.on('-O','--log-output [I/O]','sets the Test Log output') do |io|
20
- self[:log_output] = io
13
+ unless $keep_argv.empty?
14
+ self[:opts] = nil
15
+ self[:log_level] = nil
16
+ self[:log_output] = nil
17
+ self[:opts] = true
18
+ opts = OptionParser.new do |opts|
19
+ opts.on('-L','--log-level [STRING]','sets the Test Log Level') do |string|
20
+ self[:log_level] = string.to_sym
21
+ end
22
+ opts.on('-O','--log-output [I/O]','sets the Test Log output') do |io|
23
+ self[:log_output] = io
24
+ end
21
25
  end
26
+ opts.parse!($keep_argv)
22
27
  end
23
- opts.parse!($keep_argv)
24
28
  end
25
29
 
26
30
  def self.keep_wanted_argv
@@ -42,10 +46,9 @@ class GlobaLog
42
46
  end
43
47
  $keep_argv ||= keep
44
48
  end
45
-
46
- self.keep_wanted_argv
49
+
50
+ Hijack.keep_wanted_argv
47
51
  Args.are(self.new)
48
-
49
52
  end
50
53
 
51
- end
54
+ end
@@ -0,0 +1,38 @@
1
+ # Author:: lp (mailto:lp@spiralix.org)
2
+ # Copyright:: 2009 Louis-Philippe Perron - Released under the terms of the MIT license
3
+ class GlobaLog
4
+
5
+ def debug(arg,&block)
6
+ sync_level(:debug) { super(arg,&block) }
7
+ end
8
+
9
+ def info(arg,&block)
10
+ sync_level(:info) { super(arg,&block) }
11
+ end
12
+
13
+ def warn(arg,&block)
14
+ sync_level(:warn) { super(arg,&block) }
15
+ end
16
+
17
+ def error(arg,&block)
18
+ sync_level(:error) { super(arg,&block) }
19
+ end
20
+
21
+ def fatal(arg,&block)
22
+ sync_level(:fatal) { super(arg,&block) }
23
+ end
24
+
25
+ def unknown(arg,&block)
26
+ sync_level(:unknown) { super(arg,&block) }
27
+ end
28
+
29
+ private
30
+
31
+ def sync_level(level)
32
+ self.level = Args::log_level
33
+ if Args.sym_to_level(level) >= Args::log_level
34
+ yield
35
+ end
36
+ end
37
+
38
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louis-Philippe Perron
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-26 00:00:00 -05:00
12
+ date: 2009-02-28 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,6 +25,7 @@ files:
25
25
  - lib/globalog.rb
26
26
  - lib/globalog_args.rb
27
27
  - lib/globalog_hijack.rb
28
+ - lib/globalog_runsync.rb
28
29
  - test/external_helper.rb
29
30
  - test/tc_globalog_main.rb
30
31
  has_rdoc: true