root/cleverbox/trunk/cleverbox/log.py

Revision 260, 1.1 KB (checked in by trivoallan, 4 years ago)

cleverbox :

  • Added licence information to all project's file. Fixes #28
  • Fixed version number in O.4's setup.py
Line 
1# This file is part of the "Cleverbox" program.
2#
3# Cleverbox is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# Cleverbox is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with Cleverbox.  If not, see <http://www.gnu.org/licenses/>.
15#
16# Copyright 2008, Tristan Rivoallan
17
18import logging, sys
19from cleverbox.utils import termcolors, styles
20
21class TermcolorsFormatter(logging.Formatter):
22   
23    def format(self, record):
24        msg = logging.Formatter.format(self, record)
25       
26        if record.levelno == logging.WARNING:
27            msg = styles.style.WARNING(msg)
28       
29        if record.levelno == logging.ERROR:
30            msg = styles.style.ERROR(msg)
31
32        return msg
Note: See TracBrowser for help on using the browser.