Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* added fatal methods since they are just missing

* check before triggering the log event, i.e. have string operations only when logging takes place
  • Loading branch information...
commit 4453216712a21626f7494a979715c53cb72522f3 1 parent 9723b41
@mkristian authored
View
6 History.txt
@@ -1,3 +1,9 @@
+=== 0.3.1 / 2010-05-12
+
+* added fatal methods since they are just missing
+
+* check before triggering the log event, i.e. have string operations only when logging takes place
+
=== 0.3.0 / 2010-05-09
* added pom.xml for maven build
View
39 lib/slf4r/abstract_logger_facade.rb
@@ -23,6 +23,10 @@ def _error(msg)
raise NotImplementedError
end
+ def _fatal(msg)
+ raise NotImplementedError
+ end
+
public
attr_reader :name
@@ -36,8 +40,10 @@ def debug?
end
def debug(msg = nil, exception = nil)
- msg, exception = yield if block_given?
- _debug("#{msg}#{format(exception)}")
+ if(debug?)
+ msg, exception = yield if block_given?
+ _debug("#{msg}#{format(exception)}")
+ end
end
def info?
@@ -45,8 +51,10 @@ def info?
end
def info(msg = nil, exception = nil)
- msg, exception = yield if block_given?
- _info("#{msg}#{format(exception)}")
+ if(info?)
+ msg, exception = yield if block_given?
+ _info("#{msg}#{format(exception)}")
+ end
end
def warn?
@@ -54,8 +62,10 @@ def warn?
end
def warn(msg = nil, exception = nil)
- msg, exception = yield if block_given?
- _warn("#{msg}#{format(exception)}")
+ if(warn?)
+ msg, exception = yield if block_given?
+ _warn("#{msg}#{format(exception)}")
+ end
end
def error?
@@ -63,8 +73,21 @@ def error?
end
def error(msg = nil, exception = nil)
- msg, exception = yield if block_given?
- _error("#{msg}#{format(exception)}")
+ if(error?)
+ msg, exception = yield if block_given?
+ _error("#{msg}#{format(exception)}")
+ end
+ end
+
+ def fatal?
+ raise NotImplementedError
+ end
+
+ def fatal(msg = nil, exception = nil)
+ if(fatal?)
+ msg, exception = yield if block_given?
+ _fatal("#{msg}#{format(exception)}")
+ end
end
end
end
View
2  lib/slf4r/java_logger.rb
@@ -19,7 +19,7 @@ def initialize(name)
@logger = org.slf4j.LoggerFactory.getLogger(name.to_s.sub(/^::/, '').gsub(/::/, '.'))
end
- [:debug, :info, :warn, :error].each do |level|
+ [:debug, :info, :warn, :error, :fatal].each do |level|
class_eval <<-CODE
def #{level}?
@logger.is_#{level}_enabled
View
16 lib/slf4r/log4r_logger.rb
@@ -14,7 +14,7 @@ def initialize(name)
public
def debug?
- @logger.level == 0
+ @logger.level == Log4r::DEBUG
end
def _debug(msg)
@@ -22,7 +22,7 @@ def _debug(msg)
end
def info?
- @logger.level <= 1
+ @logger.level <= Log4r::INFO
end
def _info(msg)
@@ -30,7 +30,7 @@ def _info(msg)
end
def warn?
- @logger.level <= 2
+ @logger.level <= Log4r::WARN
end
def _warn(msg)
@@ -38,12 +38,20 @@ def _warn(msg)
end
def error?
- @logger.level <= 3
+ @logger.level <= Log4r::ERROR
end
def _error(msg)
@logger.error(msg)
end
+ def fatal?
+ @logger.level <= Log4r::FATAL
+ end
+
+ def _fatal(msg)
+ @logger.fatal(msg)
+ end
+
end
end
View
8 lib/slf4r/logging_logger.rb
@@ -43,6 +43,10 @@ def _error(msg)
log(3, msg)
end
+ def _fatal(msg)
+ log(4, msg)
+ end
+
public
def debug?
@@ -60,5 +64,9 @@ def warn?
def error?
@logger.level <= 3
end
+
+ def fatal?
+ @logger.level <= 4
+ end
end
end
View
7 lib/slf4r/noop_logger.rb
@@ -36,5 +36,12 @@ def error?
def error(msg = nil, exception = nil)
end
+
+ def fatal?
+ false
+ end
+
+ def fatal(msg = nil, exception = nil)
+ end
end
end
View
8 lib/slf4r/ruby_logger.rb
@@ -61,6 +61,10 @@ def _error(msg)
log(::Logger::ERROR, msg)
end
+ def _fatal(msg)
+ log(::Logger::FATAL, msg)
+ end
+
public
def debug?
@@ -78,5 +82,9 @@ def warn?
def error?
@logger.error?
end
+
+ def fatal?
+ @logger.fatal?
+ end
end
end
View
2  lib/slf4r/version.rb
@@ -1,3 +1,3 @@
module Slf4r
- VERSION = '0.3.0'
+ VERSION = '0.3.1'
end
View
8 lib/slf4r/wrapped_logger.rb
@@ -39,6 +39,10 @@ def _error(msg)
@logger.error(msg)
end
+ def _fatal(msg)
+ @logger.fatal(msg)
+ end
+
public
def debug?
@@ -56,5 +60,9 @@ def warn?
def error?
@logger.error?
end
+
+ def fatal?
+ @logger.fatal?
+ end
end
end
View
76 pom.xml
@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>rubygems</groupId>
<artifactId>slf4r</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <version>0.3.1</version>
<packaging>gem</packaging>
<name>Slf4r</name>
<description>Slf4r provides a uniform interface for instantiating und using of a logger</description>
@@ -14,11 +14,11 @@
<repository>
<id>rubygems</id>
<releases>
- <updatePolicy>never</updatePolicy>
- <checksumPolicy>ignore</checksumPolicy>
+ <updatePolicy>never</updatePolicy>
+ <checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
- <enabled>false</enabled>
+ <enabled>false</enabled>
</snapshots>
<url>http://rubygems.org/gems</url>
<layout>gem</layout>
@@ -80,51 +80,51 @@
<build>
<plugins>
<plugin>
- <groupId>de.saumya.mojo</groupId>
- <artifactId>gem-maven-plugin</artifactId>
- <version>${jruby.plugins.version}</version>
+ <groupId>de.saumya.mojo</groupId>
+ <artifactId>gem-maven-plugin</artifactId>
+ <version>${jruby.plugins.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
- <groupId>de.saumya.mojo</groupId>
- <artifactId>rspec-maven-plugin</artifactId>
- <version>${jruby.plugins.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <specSourceDirectory>${basedir}/spec</specSourceDirectory>
- </configuration>
- </execution>
- </executions>
+ <groupId>de.saumya.mojo</groupId>
+ <artifactId>rspec-maven-plugin</artifactId>
+ <version>${jruby.plugins.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <specSourceDirectory>spec</specSourceDirectory>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>jruby-maven-plugin</artifactId>
- <version>${jruby.plugins.version}</version>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>jruby</goal>
- </goals>
- <configuration>
- <script>
- puts "module Slf4r"
- puts " VERSION = '${project.version}'".sub(/-SNAPSHOT/, '')
- puts "end"
- </script>
- <outputFile>lib/slf4r/version.rb</outputFile>
- </configuration>
- </execution>
- </executions>
+ <version>${jruby.plugins.version}</version>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>jruby</goal>
+ </goals>
+ <configuration>
+ <script>
+ puts "module Slf4r"
+ puts " VERSION = '${project.version}'".sub(/-SNAPSHOT/, '')
+ puts "end"
+ </script>
+ <outputFile>lib/slf4r/version.rb</outputFile>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <jruby.plugins.version>0.11.1</jruby.plugins.version>
+ <jruby.plugins.version>0.12.0-SNAPSHOT</jruby.plugins.version>
</properties>
</project>
Please sign in to comment.
Something went wrong with that request. Please try again.