Skip to content

Commit

Permalink
set log level :fatal to default and remove unneeded use of log level …
Browse files Browse the repository at this point in the history
…configuration
  • Loading branch information
Vincent Landgraf committed Aug 28, 2008
1 parent 367be54 commit 217c8a1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
3 changes: 0 additions & 3 deletions default-server/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ end
# load all local queues (from project directory)
Dir.glob("queues/*.rb").each { |f| require f }

# setup log level of free message queue
FreeMessageQueue.log_level("info")

# =====================================================
# create and configure the queue manager
# =====================================================
Expand Down
28 changes: 10 additions & 18 deletions lib/fmq/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,27 @@ module FreeMessageQueue
# free message queue, so that it is simple to access
# the logger from somewhere in the project
def self.logger
$FMQ_GLOBAL_LOGGER ||= create_logger
$FMQ_GLOBAL_LOGGER ||= FreeMessageQueue.create_logger
end

# This method creates the logger instance once (even if it is called twice).
# it is by default on fatal
def self.create_logger(log_to = STDOUT)
$FMQ_GLOBAL_LOGGER ||= Logger.new(log_to)
FreeMessageQueue.log_level(:fatal)
return $FMQ_GLOBAL_LOGGER
end

# This method sets the log level of the fmq logger
# the level must be a string (either downcase or upcase)
# that contains one of the following levels:
# * FATAL => Server side errors
# * ERROR => Server side error backtraces
# * WARN => Client side errors
# * INFO => Setup information (config stuff etc.)
# * DEBUG => All operations of the queue manager and others
# * :fatal => Server side errors
# * :error => Server side error backtraces
# * :warn => Client side errors
# * :info => Setup information (config stuff etc.)
# * :debug => All operations of the queue manager and others
def self.log_level(level)
case level
when /fatal/i
FreeMessageQueue.logger.level = Logger::FATAL
when /error/i
FreeMessageQueue.logger.level = Logger::ERROR
when /warn/i
FreeMessageQueue.logger.level = Logger::WARN
when /info/i
FreeMessageQueue.logger.level = Logger::INFO
when /debug/i
FreeMessageQueue.logger.level = Logger::DEBUG
end
FreeMessageQueue.logger.level = eval("Logger::#{level.to_s.upcase}")
FreeMessageQueue.logger.debug "[Logger] set log level to #{level}"
end

Expand Down
2 changes: 0 additions & 2 deletions test/test_queue_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ class TestQueueManager < Test::Unit::TestCase
DEFAULT_QUEUE_NAME = "/fmq_test/test1"

def setup
FreeMessageQueue.log_level "info"

@queue_manager = FreeMessageQueue::QueueManager.new(false) do
setup_queue DEFAULT_QUEUE_NAME do |q|
q.max_messages = 100
Expand Down

0 comments on commit 217c8a1

Please sign in to comment.