pyplusplus._logging_

Package pyplusplus :: Package _logging_ |

# Source Code for Package pyplusplus._logging_

     1  # Copyright 2004-2008 Roman Yakovenko.
     2  # Distributed under the Boost Software License, Version 1.0. (See
     3  # accompanying file LICENSE_1_0.txt or copy at
     4  # http://www.boost.org/LICENSE_1_0.txt)
     5  #TODO: find better place for it
     6
     7  """defines logger classes"""
     8
     9  import os
    10  import sys
    11  import logging
    12  from multi_line_formatter import multi_line_formatter_t
    13
    14 -def _create_logger_( name ):
    15      """implementation details"""
    16      logger = logging.getLogger(name)
    17      handler = logging.StreamHandler()
    18      handler.setFormatter( multi_line_formatter_t( os.linesep + '%(levelname)s: %(message)s' ) )
    19      logger.addHandler(handler)
    20      logger.setLevel(logging.INFO)
    21      return logger
    22
    23 -class loggers:
    24      """class-namespace, defines few loggers classes, used in the project"""
    25
    26      file_writer = _create_logger_( 'pyplusplus.file_writer' )
    27      """logger for classes that write code to files"""
    28
    29      declarations = _create_logger_( 'pyplusplus.declarations' )
    30      """logger for declaration classes
    31
    32      This is very import logger. All important messages: problems with declarations,
    33      warnings or hints are written to this logger.
    34      """
    35
    36      module_builder = _create_logger_( 'pyplusplus.module_builder' )
    37      """logger that in use by L{module_builder_t} class.
    38
    39      Just another logger. It exists mostly for Py++ developers.
    40      """
    41
    42      #root logger exists for configuration purpose only
    43      root = logging.getLogger( 'pyplusplus' )
    44      """root logger exists for your convinience only"""
    45
    46      all = [ root, file_writer, module_builder, declarations ]
    47      """contains all logger classes, defined by the class"""
    48