log.py revision 2537
#
# 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
# the action and manifest we expect messages from. See advise()
# when the logger is using an engine, the engine registers
# itself here
# 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."""
"""Called to tell the logger to expect lint messages concerning
if action:
if manifest:
class PlainLogFormatter(LogFormatter):
"""A basic log formatter, just prints the message."""
return
# Format the message level and message identifier
if not ignore_linted:
try:
except DuplicateLintedAttrException, err:
lint_key = ("%s pkglint001.6" %
_("Logging error: %s") % err))
if linted_flag:
# we may have asked not to report errors
# that have been marked as pkg.linted
"pkglint001.5.report-linted")
if report and \
return
linted_msg = _(
"Linted message: %(id)s "
"%(msg)s") % \
return
# We only treat errors, and criticals as being worthy
# of a flag (pkglint returns non-zero if self.emitted)