YUKI Hiroshi
null+****@clear*****
Wed Jul 24 12:58:44 JST 2013
YUKI Hiroshi 2013-07-24 12:58:44 +0900 (Wed, 24 Jul 2013) New Revision: 564572cb8799cee3e8a53508794b800933680c3e https://github.com/groonga/fluent-plugin-droonga/commit/564572cb8799cee3e8a53508794b800933680c3e Message: Define Droonga::Logger.info/error to wrap $log.info/error Added files: lib/droonga/logger.rb Modified files: lib/droonga/handler.rb lib/droonga/plugin/handler_forward.rb Modified: lib/droonga/handler.rb (+5 -7) =================================================================== --- lib/droonga/handler.rb 2013-07-23 17:18:29 +0900 (15500a8) +++ lib/droonga/handler.rb 2013-07-24 12:58:44 +0900 (750dec8) @@ -17,6 +17,7 @@ require "droonga/handler_plugin" require "droonga/command_mapper" +require "droonga/logger" module Droonga class Handler @@ -66,13 +67,10 @@ module Droonga def handle(command, request, *arguments) __send__(self.class.method_name(command), request, *arguments) rescue => exception - if $log - $log.error "error while handling #{command}", - request: request, - arguments: arguments, - exception: exception - $log.error_backtrace - end + Logger.error("error while handling #{command}", + request: request, + arguments: arguments, + exception: exception) end def prefer_synchronous?(command) Added: lib/droonga/logger.rb (+34 -0) 100644 =================================================================== --- /dev/null +++ lib/droonga/logger.rb 2013-07-24 12:58:44 +0900 (ae85ce1) @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2013 droonga project +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +module Droonga + module Logger + module_function + def info(message) + if $log + $log.info(message) + end + end + + def error(message, additional_information={}) + if $log + $log.error(message, additional_information) + $log.error_backtrace + end + end + end +end Modified: lib/droonga/plugin/handler_forward.rb (+6 -11) =================================================================== --- lib/droonga/plugin/handler_forward.rb 2013-07-23 17:18:29 +0900 (be73792) +++ lib/droonga/plugin/handler_forward.rb 2013-07-24 12:58:44 +0900 (224b556) @@ -16,6 +16,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA require "droonga/handler" +require "droonga/logger" module Droonga class MergeHandler < Droonga::Handler @@ -32,13 +33,10 @@ module Droonga post(request, "to" => destination, "type" => command, "arguments" => arguments) rescue => exception - if $log - $log.error "error while handling #{command}", - request: request, - arguments: arguments, - exception: exception - $log.error_backtrace - end + Logger.error("error while handling #{command}", + request: request, + arguments: arguments, + exception: exception) end def get_destination @@ -65,10 +63,7 @@ module Droonga end @config_mtime = mtime rescue => exception - if $log - $log.error "error while refreshing config", exception: exception - $log.error_backtrace - end + Logger.error("error while refreshing config", exception: exception) @config = nil end end -------------- next part -------------- HTML����������������������������...Download