log.py revision 2046
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
#
import logging
import sys
import os
# a set of lint messages that can be produced.
LEVELS = {
"DEBUG": DEBUG,
"INFO": INFO,
"WARNING": WARNING,
"ERROR": ERROR,
"CRITICAL": CRITICAL,
# we are our own reverse map
DEBUG: "DEBUG",
INFO: "INFO",
WARNING: "WARNING",
ERROR: "ERROR",
CRITICAL: "CRITICAL"
}
class LintMessage(object):
"""A base class for all lint messages."""
msg = ""
def __unicode__(self):
""""Inspect a given pkg.client.progress.ProgressTracker, telling it
to flush, before emitting output."""
else:
class LogFormatter(object):
"""A class that formats log messages."""
# install our own logger, writing to stderr
# to our private log handler
def _get_tracker(self):
def _del_tracker(self):
# string values for what's always stored as an integer
def _get_level(self):
raise ValueError(
_("%(value)s is not a valid level") % value)
else:
def _del_level(self):
# convenience methods to log messages
"""Start a new log file"""
pass
"""Given a LintMessage message, format that object
appropriately."""
pass
"""End a log file"""
pass
def produced_lint_msgs(self):
"""Called to determine if this logger produced any lint
messages at a level >= its log level."""
class PlainLogFormatter(LogFormatter):
"""A basic log formatter, just prints the message."""
# could perhaps format this better
# We only treat warnings, errors, and criticals
# as being worthy of a flag
# (pkglint returns non-zero if self.emitted)
else: