All Samples(1690) | Call(1533) | Derive(117) | Import(40)
Formatter instances are used to convert a LogRecord to text.
Formatters need to know how a LogRecord is constructed. They are
responsible for converting a LogRecord to (usually) a string which can
be interpreted by either a human or an external system. The base Formatter
allows a formatting string to be specified. If none is supplied, the
default value of "%s(message)\n" is used.
The Formatter can be initialized with a format string which makes use of
knowledge of the LogRecord attributes - e.g. the default value mentioned
above makes use of the fact that the user's message and arguments are pre-
formatted into a LogRecord's message attribute. Currently, the useful
attributes in a LogRecord are described by:
%(name)s Name of the logger (logging channel)
%(levelno)s Numeric logging level for the message (DEBUG, INFO,
WARNING, ERROR, CRITICAL)
%(levelname)s Text logging level for the message ("DEBUG", "INFO",
"WARNING", "ERROR", "CRITICAL")
%(pathname)s Full pathname of the source file where the logging
call was issued (if available)
%(filename)s Filename portion of pathname
%(module)s Module (name portion of filename)
%(lineno)d Source line number where the logging call was issued
(if available)
%(funcName)s Function name
%(created)f Time when the LogRecord was created (time.time()
return value)
%(asctime)s Textual time when the LogRecord was created
%(msecs)d Millisecond portion of the creation time
%(relativeCreated)d Time in milliseconds when the LogRecord was created,
relative to the time the logging module was loaded
(typically at application startup time)
%(thread)d Thread ID (if available)
%(threadName)s Thread name (if available)
%(process)d Process ID (if available)
%(message)s The result of record.getMessage(), computed just as
the record is emittedsrc/p/y/pyogp.apps-0.1dev/pyogp/apps/examples/parse_packets.py pyogp.apps(Download)
import traceback
from pyogp.lib.base.message.udpdeserializer import UDPMessageDeserializer
from pyogp.lib.base.settings import Settings
from logging import getLogger, StreamHandler, Formatter, CRITICAL, ERROR, WARNING, INFO, DEBUG
logger = getLogger('parse_packet')
def enable_logging():
console = StreamHandler()
console.setLevel(DEBUG) # seems to be a no op, set it for the logger
formatter = Formatter('%(name)-30s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
getLogger('').addHandler(console)
src/c/l/cli-HEAD/lib/cli/log.py cli(Download)
import logging import sys from logging import Formatter, StreamHandler from cli.app import CommandLineApp, CommandLineMixin, Application
# Create logger.
logging.setLoggerClass(CommandLineLogger)
self.log = logging.getLogger(self.name)
self.formatter = Formatter(fmt=self.message_format, datefmt=self.date_format)
self.log.level = self.log.default_level
src/p/y/pyCLI-1.1.1/lib/cli/log.py pyCLI(Download)
import logging import sys from logging import Formatter, StreamHandler from cli.app import CommandLineApp, CommandLineMixin, Application
# Create logger.
logging.setLoggerClass(CommandLineLogger)
self.log = logging.getLogger(self.name)
self.formatter = Formatter(fmt=self.message_format, datefmt=self.date_format)
self.log.level = self.log.default_level
src/q/u/quintagroup.canonicalpath-0.7/quintagroup/canonicalpath/upgrades.py quintagroup.canonicalpath(Download)
import sys from types import StringTypes from logging import NOTSET, DEBUG, INFO, ERROR from logging import Logger, StreamHandler, Formatter from StringIO import StringIO from zope.component import getAdapter from Acquisition import aq_base, aq_inner
def _initLogger(self):
self._inout = StringIO()
handler = StreamHandler(self._inout)
handler.setLevel(DEBUG)
formatter = Formatter(fmt="[%(asctime)s]: %(message)s",
datefmt="%H:%M:%S")
handler.setFormatter(formatter)
src/y/a/yalib-HEAD/logutils/server.py yalib(Download)
from yalib.logutils import ColorFormatter
ColorFormatter._color = 'color'
except ImportError:
from logging import Formatter as ColorFormatter
ColorFormatter._color = 'mono'
class InvalidLogRecordError(Exception):
def invoke(self):
server_address=(self.options.bind_address, self.options.bind_port)
logging.getLogger().setLevel(self.options.log_level)
handler = logging.StreamHandler()
handler.setFormatter(ColorFormatter(datefmt=self.options.date_format, fmt=self.options.format))
handler.setLevel(self.options.log_level)
logging.getLogger().addHandler(handler)
src/p/a/papy-1.0b1/src/papy/utils/logger.py papy(Download)
Provides and setups logging facilities for *PaPy*. """ import logging from logging import handlers, Formatter import time
root_log = logging.getLogger()
formatter = Formatter(
"%(levelname)s %(asctime)s,%(msecs).3d [%(name)s] - %(message)s", \
datefmt='%H:%M:%S')
root_log.setLevel(logging.DEBUG)
if log_to_file:
src/z/e/zenoss-HEAD/trunk/Products/ZenModel/IpNetwork.py zenoss(Download)
def setupLog(self, response):
"""setup logging package to send to browser"""
from logging import StreamHandler, Formatter
root = logging.getLogger()
self._v_handler = StreamHandler(response)
fmt = Formatter("""<tr class="tablevalues">
<td>%(asctime)s</td><td>%(levelname)s</td>
<td>%(name)s</td><td>%(message)s</td></tr>
""", "%Y-%m-%d %H:%M:%S")
src/z/e/zenoss-HEAD/Products/ZenModel/IpNetwork.py zenoss(Download)
def setupLog(self, response):
"""setup logging package to send to browser"""
from logging import StreamHandler, Formatter
root = logging.getLogger()
self._v_handler = StreamHandler(response)
fmt = Formatter("""<tr class="tablevalues">
<td>%(asctime)s</td><td>%(levelname)s</td>
<td>%(name)s</td><td>%(message)s</td></tr>
""", "%Y-%m-%d %H:%M:%S")
src/z/e/zenoss-HEAD/trunk/Products/ZenModel/ZDeviceLoader.py zenoss(Download)
__version__ = "$Revision: 1.19 $"[11:-2]
import socket
from logging import StreamHandler, Formatter, getLogger
log = getLogger("zen.DeviceLoader")
import transaction
fmt = Formatter("""<tr class="tablevalues">
<td>%(asctime)s</td><td>%(levelname)s</td>
<td>%(name)s</td><td>%(message)s</td></tr>
""", "%Y-%m-%d %H:%M:%S")
self._v_handler.setFormatter(fmt)
root.addHandler(self._v_handler)
root.setLevel(10)
src/z/e/zenoss-HEAD/Products/ZenModel/ZDeviceLoader.py zenoss(Download)
__version__ = "$Revision: 1.19 $"[11:-2]
import socket
from logging import StreamHandler, Formatter, getLogger
log = getLogger("zen.DeviceLoader")
import transaction
fmt = Formatter("""<tr class="tablevalues">
<td>%(asctime)s</td><td>%(levelname)s</td>
<td>%(name)s</td><td>%(message)s</td></tr>
""", "%Y-%m-%d %H:%M:%S")
self._v_handler.setFormatter(fmt)
root.addHandler(self._v_handler)
root.setLevel(10)
1 | 2 | 3 | 4 Next