1 """
2 Logging module for Pyjamas, mimicking CPython's logging module.
3
4 Usage example::
5
6 from pyjamas import logging
7 log = logging.getConsoleLogger()
8 log.debug('This is a debug message')
9 """
10 __author__ = 'Peter Bittner <peter.bittner@gmx.net>'
11
12 from pyjamas.logging.handlers import \
13 AlertHandler, AppendHandler, ConsoleHandler, NullHandler
14
15 from logging import getLogger, Formatter, StreamHandler, DEBUG, BASIC_FORMAT
16
17
18 PLAIN_FORMAT = '%(message)s'
19
21 """Use this function to easily include new loggers in your application,
22 e.g. <code>log = logging.getLoggerForHandler(NullHandler())</code>"""
23 formatter = Formatter(fmt)
24 handler.setFormatter(formatter)
25 logger = getLogger(name)
26 logger.setLevel(level)
27 logger.addHandler(handler)
28 return logger
29
33
37
41
45
47 """A logger that prints text to cerr, the default error output stream."""
48 return getLoggerForHandler(StreamHandler(), name, level, fmt)
49