Beispiel #1
0
def setup_logging(logger_name, verbose_level: int=0, filename: str=None):
    level = None
    if verbose_level == -1:
        level = logging.CRITICAL
    if verbose_level is 0:
        level = logging.INFO
    elif verbose_level >= 1:
        level = logging.DEBUG

    formatter = logging.Formatter(fmt="%(asctime)-10s%(message)s", datefmt="%H:%M:%S")

    stdout_handler = ColorizingStreamHandler()
    stdout_handler.setFormatter(formatter)
    stdout_handler.stream = sys.stderr

    if not filename:
        filename = 'last.log'
    file_handler = logging.FileHandler(filename=filename, mode='w')
    file_handler.setFormatter(formatter)

    root = logging.getLogger()
    root.addHandler(stdout_handler)
    root.addHandler(file_handler)

    root.setLevel(level)

    return logging.getLogger(logger_name)
Beispiel #2
0
Usage:

>>> import log
>>> logger = log.getlogger("TestLogger")
>>> logger.info("this is some information")
[time]<TestLogger>INFO:this is some  information

"""

import os
import logging
from ansistrm import ColorizingStreamHandler
LOG_LEVEL =  logging.DEBUG

handler = ColorizingStreamHandler()
handler.setFormatter(logging.Formatter("[%(asctime)s]<%(name)s>%(levelname)s:%(message)s", None))
handler.setLevel(logging.DEBUG)

root = logging.getLogger()
root.addHandler(handler)

import logging.handlers

def getlogger(name, level=LOG_LEVEL):
    base_path = '/tmp/celery_example/'
    if not os.path.exists(base_path):
        os.makedirs(base_path)
    filename = os.path.join(base_path,'main.log')
    logger = logging.getLogger(name)
    handler = logging.handlers.RotatingFileHandler(filename, maxBytes=2**30, backupCount=10)
Beispiel #3
0
from modules.mail import *
from modules.dns import Dns, DNSList
try:
	import fcntl
except:
	fcntl = None

__author__  = 'Lukas Schreiner'
__copyright__ = 'Copyright (C) 2013 - 2015 Website-Team Friedrich-List-Schule-Wiesbaden'
__version__ = '0.8'

FORMAT = '%(asctime)-15s %(message)s'
formatter = logging.Formatter(FORMAT, datefmt='%b %d %H:%M:%S')
log = logging.getLogger('flscp')
log.setLevel(logging.INFO)
hdlr = ColorizingStreamHandler()
hdlr.setFormatter(formatter)
log.addHandler(hdlr)

workDir = os.path.dirname(os.path.realpath(__file__))

# search for config
conf = FLSConfig()
fread = conf.read(
		[
			'server.ini', os.path.expanduser('~/.flscpserver.ini'), os.path.expanduser('~/.flscp/server.ini'),
			os.path.expanduser('~/.config/flscp/server.ini'), '/etc/flscp/server.ini', '/usr/local/etc/flscp/server.ini'
		]
	)
if len(fread) <= 0:
	sys.stderr.write(
import logging
import functools

import yaml
import requests

from fabric.api import *  # noqa
from datetime import datetime
from ansistrm import ColorizingStreamHandler


logger = logging.getLogger()
logger.setLevel(logging.INFO)
formatter = logging.Formatter(
    '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler = ColorizingStreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)
'''
Fabric logging messages have their own hardcoded format and will thus not follow the
formatter format. See also https://github.com/fabric/fabric/issues/163
'''

# fabric settings
env.timeout = 10
env.forward_agent = True
env.skip_bad_hosts = True
env.colorize_errors = True
env.abort_on_prompts = True
env.connection_attempts = 3
env.disable_known_hosts = True
Beispiel #5
0
                '''


            while True:
                '''listend world or dialogues'''
                pass

        except KeyboardInterrupt:
            self.stop_services()
            logger.info("Bye bye")


# TESTING
#------------------------------
if __name__=='__main__':

    from ansistrm import ColorizingStreamHandler

    console = ColorizingStreamHandler()

    logger.setLevel(logging.INFO)

    formatter = logging.Formatter('%(asctime)-15s: %(message)s')
    console.setFormatter(formatter)
    logger.addHandler(console)

    kb = kb.KB()
    process = processKB(kb)

    process()
Beispiel #6
0
~~~

This module customize the logging handler so that we can acheive a colorful output

Usage:

>>> import log
>>> logger = log.getlogger("TestLogger")
>>> logger.info("this is some information")
[time]<TestLogger>INFO:this is some  information

"""
import logging
from ansistrm import ColorizingStreamHandler

handler = ColorizingStreamHandler()
handler.setFormatter(
    logging.Formatter("[%(asctime)s]<%(name)s>%(levelname)s:%(message)s",
                      None))
handler.setLevel(logging.DEBUG)

root = logging.getLogger()
root.addHandler(handler)

import logging.handlers


def getlogger(name, filename='/tmp/pythoner_server.log', level=logging.DEBUG):
    logger = logging.getLogger(name)
    handler = logging.handlers.RotatingFileHandler(filename,
                                                   maxBytes=2**30,
Beispiel #7
0
        logging.Handler.__init__(self)

    def emit(self, record):
        if record.levelno == 40 and self.ignoreError == False:
            exit(1)


logging.addLevelName(CustomLoggingLevel.BASIC_DEBUG, "BASIC DEBUG")
logging.addLevelName(CustomLoggingLevel.IMAGE_DEBUG, "IMAGE DEBUG")
logging.addLevelName(CustomLoggingLevel.ASCII_DATA, "ASCII DATA")
logging.addLevelName(CustomLoggingLevel.OTHER_DATA, "OTHER DATA")
logging.addLevelName(CustomLoggingLevel.EXTRA_DATA, "EXTRA DATA")
logging.addLevelName(CustomLoggingLevel.STEGO_DATA, "STEGO DATA")
logging.addLevelName(CustomLoggingLevel.IMAGE_INFO, "IMAGE INFO")

stream_handler = ColorizingStreamHandler(sys.stdout)
stream_handler.level_map[logging.getLevelName("BASIC DEBUG")] = (None, "cyan",
                                                                 False)
stream_handler.level_map[logging.getLevelName("IMAGE DEBUG")] = (None,
                                                                 "magenta",
                                                                 False)

formatter = logging.Formatter('[%(asctime)s][%(levelname)s] %(message)s', \
            '%H:%M:%S')
stream_handler.setFormatter(formatter)

errorHandler = ErrorHandler()

LOGGER = logging.getLogger('StegoDetector')
LOGGER.setLevel(1)