mini_logger 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'logger'
3
+
4
+
5
+ module MiniLogger
6
+ extend self
7
+
8
+ DEBUG = ::Logger::DEBUG
9
+ INFO = ::Logger::INFO
10
+ WARN = ::Logger::WARN
11
+ ERROR = ::Logger::ERROR
12
+ FATAL = ::Logger::FATAL
13
+
14
+ DEFAULT_LOGCHANNEL = STDERR
15
+ DEFAULT_LOGLEVEL = DEBUG
16
+ VALID_METHODS = [ :debug, :info, :warn, :error, :fatal ]
17
+
18
+
19
+ def configure( atts = {} )
20
+
21
+ atts[:log_channel] ||= DEFAULT_LOGCHANNEL
22
+ atts[:log_channel] ||= DEFAULT_LOGLEVEL
23
+
24
+ @logger ||= ::Logger.new( atts[:log_channel] )
25
+ @logger.level ||= atts[:log_level]
26
+
27
+ self
28
+ end
29
+
30
+ def debug?
31
+ (@logger.level == DEBUG)
32
+ end
33
+
34
+ def level
35
+ @logger.level
36
+ end
37
+
38
+
39
+ def level=( new_level )
40
+ @logger.level=new_level
41
+ end
42
+
43
+
44
+ def method_missing( method, *arguments, &block )
45
+
46
+ self.configure unless @logger
47
+
48
+ if( VALID_METHODS.include?( method ) )
49
+ if( block_given? )
50
+ @logger.send( method, arguments.length == 1 ? arguments[0] : arguments, block )
51
+ else
52
+ @logger.send( method, arguments.length == 1 ? arguments[0] : arguments )
53
+ end
54
+ end
55
+ end
56
+ end
@@ -3,10 +3,10 @@ module MiniLogger
3
3
  INFO = {
4
4
  :major =>0,
5
5
  :minor =>2,
6
- :patch =>3
6
+ :patch =>4
7
7
  }
8
8
 
9
- NAME = 'mini_logger'
10
- VERSION = INFO.values.join( '.' )
9
+ NAME = 'mini_logger'
10
+ NUMBER = INFO.values.join( '.' )
11
11
  end
12
12
  end
@@ -0,0 +1,46 @@
1
+ $:.unshift( File.join( File.dirname( __FILE__ ), %w[.. .. lib] ) )
2
+
3
+
4
+ require 'rubygems'
5
+ require 'shoulda'
6
+ require 'mini_logger'
7
+
8
+
9
+ class TestMiniLogger < Test::Unit::TestCase
10
+
11
+ context "A Default Logger" do
12
+
13
+ setup do
14
+ MiniLogger.configure( :log_channel=>STDOUT, :log_level=>MiniLogger::DEBUG )
15
+ end
16
+
17
+ should "be level DEBUG" do
18
+ assert( MiniLogger.debug? )
19
+ end
20
+
21
+ should "write a debug line" do
22
+ assert( MiniLogger.debug( "debug" ) )
23
+ end
24
+
25
+ should "write a info line" do
26
+ assert( MiniLogger.info( "info" ) )
27
+ end
28
+
29
+ should "write a warn line" do
30
+ assert( MiniLogger.warn( "warn" ) )
31
+ end
32
+
33
+ should "write a error line" do
34
+ assert( MiniLogger.error( "error" ) )
35
+ end
36
+
37
+ should "write a fatal line" do
38
+ assert( MiniLogger.fatal( "fatal" ) )
39
+ end
40
+
41
+ should "change log level" do
42
+ MiniLogger.level = MiniLogger::ERROR
43
+ assert_equal( MiniLogger.level, MiniLogger::ERROR )
44
+ end
45
+ end
46
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mini_logger
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Javier Juarez
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-04 00:00:00 +01:00
13
+ date: 2011-03-05 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -23,9 +23,9 @@ extensions: []
23
23
  extra_rdoc_files:
24
24
  - README.rdoc
25
25
  files:
26
- - lib/mini_logger.rb
27
- - lib/version.rb
28
- - test/unit/tc_mini_logger.rb
26
+ - lib/mini_logger/mini_logger.rb
27
+ - lib/mini_logger/version.rb
28
+ - test/test_mini_logger.rb
29
29
  - README.rdoc
30
30
  has_rdoc: true
31
31
  homepage: http://github.com/jjuarez/mini_logger
@@ -56,4 +56,4 @@ signing_key:
56
56
  specification_version: 3
57
57
  summary: A real simple logger utility
58
58
  test_files:
59
- - test/unit/tc_mini_logger.rb
59
+ - test/test_mini_logger.rb
data/lib/mini_logger.rb DELETED
@@ -1,31 +0,0 @@
1
- require 'rubygems'
2
- require 'logger'
3
-
4
-
5
- module MiniLogger
6
- extend self
7
-
8
- DEFAULT_CONFIGURATION = { :log_channel=>STDERR, :log_level=>::Logger::INFO }
9
- VALID_METHODS = [ :debug, :info, :warn, :error, :fatal ]
10
-
11
- def configure( atts = DEFAULT_CONFIGURATION )
12
-
13
- @logger ||= ::Logger.new( atts[:log_channel] )
14
- @logger.level ||= atts[:log_level]
15
-
16
- self
17
- end
18
-
19
- def method_missing( method, *arguments, &block )
20
-
21
- self.configure unless @logger
22
-
23
- if( VALID_METHODS.include?( method ) )
24
- if( block_given? )
25
- @logger.send( method, arguments.length == 1 ? arguments[0] : arguments, block )
26
- else
27
- @logger.send( method, arguments.length == 1 ? arguments[0] : arguments )
28
- end
29
- end
30
- end
31
- end
@@ -1,41 +0,0 @@
1
- $:.unshift( File.join( File.dirname( __FILE__ ), %w[.. .. lib] ) )
2
-
3
-
4
- require 'rubygems'
5
- require 'test/unit'
6
- require 'shoulda'
7
- require 'mini_logger'
8
-
9
-
10
- class TestMiniLogger < Test::Unit::TestCase
11
-
12
- context "A Logger" do
13
-
14
- MiniLogger.configure( :log_channel=>STDOUT, :log_level=>::Logger::DEBUG )
15
- end
16
-
17
- should "Debug" do
18
-
19
- assert( MiniLogger.debug( "debug XXX" ) )
20
- end
21
-
22
- should "Info" do
23
-
24
- assert( MiniLogger.info( "info XXX" ) )
25
- end
26
-
27
- should "Warn" do
28
-
29
- assert( MiniLogger.warn( "warn XXX" ) )
30
- end
31
-
32
- should "Error" do
33
-
34
- assert( MiniLogger.error( "error XXX" ) )
35
- end
36
-
37
- should "Fatal" do
38
-
39
- assert( MiniLogger.fatal( "fatal XXX" ) )
40
- end
41
- end