Hi.
Although I'm not familiar with logging system,
this kinds of feature can be realized naturally by something like
setting format, overriding formatter with logging framework?

thanks,

On Tue, Mar 05, 2013 at 01:18:09PM +0900, YAMAMOTO Takashi wrote:
> this will be used by cli app.
> 
> Signed-off-by: YAMAMOTO Takashi <[email protected]>
> ---
>  ryu/plogger.py | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>  create mode 100644 ryu/plogger.py
> 
> diff --git a/ryu/plogger.py b/ryu/plogger.py
> new file mode 100644
> index 0000000..c95a461
> --- /dev/null
> +++ b/ryu/plogger.py
> @@ -0,0 +1,31 @@
> +# Copyright (C) 2013 Nippon Telegraph and Telephone Corporation.
> +# Copyright (C) 2013 YAMAMOTO Takashi <yamamoto at valinux co jp>
> +#
> +# Licensed under the Apache License, Version 2.0 (the "License");
> +# you may not use this file except in compliance with the License.
> +# You may obtain a copy of the License at
> +#
> +#    http://www.apache.org/licenses/LICENSE-2.0
> +#
> +# Unless required by applicable law or agreed to in writing, software
> +# distributed under the License is distributed on an "AS IS" BASIS,
> +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> +# implied.
> +# See the License for the specific language governing permissions and
> +# limitations under the License.
> +
> +
> +class PrefixedLogger(object):
> +    def __init__(self, logger, prefix):
> +        self.logger = logger
> +        self.prefix = prefix
> +
> +    def __getattr__(self, name):
> +        basemethod = getattr(self.logger, name)
> +        if not name in ['debug', 'info', 'warn', 'error', 'critical',
> +                        'exception']:
> +            raise AttributeError
> +
> +        def method(msg, *args, **kwargs):
> +            return basemethod("%s %s" % (self.prefix, msg), *args, **kwargs)
> +        return method
> -- 
> 1.8.0.1
> 
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

-- 
yamahata

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to