<commit_before>##
## Author(s):
##  - <NAME> <<EMAIL>>
##
## Copyright (C) 2013 Aldebaran Robotics
##

from _qi import pylog
from _qi import pysetlevel
from _qi import pysetcontext
from _qi import pysetfilters
import inspect
import uuid

def logGetTraceInfo():
    callerframerecord = inspect.stack()[2]    # 0 represents this line
    frame = callerframerecord[0]
    info = inspect.getframeinfo(frame)
    return info

# Log Level
FATAL   = 1
ERROR   = 2
WARNING = 3
INFO    = 4
VERBOSE = 5
DEBUG   = 6

def setLevel(level):
    pysetlevel(level)

def setContext(context):
    pysetcontext(context)

def setFilters(filters):
    pysetfilters(filters)

def _printToString(*args):
    return ' '.join(str(x) for x in args)

class PyLogger:
    def __init__(self, category):
        self.category = category

    def fatal(self, *args):
        info = logGetTraceInfo()
        pylog(1, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def error(self, *args):
        info = logGetTraceInfo()
        pylog(2, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def warning(self, *args):
        info = logGetTraceInfo()
        pylog(3, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def info(self, *args):
        info = logGetTraceInfo()
        pylog(4, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def debug(self, *args):
        info = logGetTraceInfo()
        pylog(5, self.category, _printToString(*args), info.filename, info.function, info.lineno)

def getLogger( name):
    return PyLogger(name)

def logSilent(cat, *args):
    info = logGetTraceInfo()
    pylog(0, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logFatal(cat, *args):
    info = logGetTraceInfo()
    pylog(1, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logError(cat, *args):
    info = logGetTraceInfo()
    pylog(2, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logWarning(cat, *args):
    info = logGetTraceInfo()
    pylog(3, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logInfo(cat, *args):
    info = logGetTraceInfo()
    pylog(4, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logVerbose(cat, *args):
    info = logGetTraceInfo()
    pylog(5, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logDebug(cat, *args):
    info = logGetTraceInfo()
    pylog(6, cat, _printToString(*args), info.filename, info.function, info.lineno)<commit_msg>[python] Fix log levels, bind debug to verbose<commit_after>##
## Author(s):
##  - <NAME> <<EMAIL>>
##
## Copyright (C) 2013 Aldebaran Robotics
##

from _qi import pylog
from _qi import pysetlevel
from _qi import pysetcontext
from _qi import pysetfilters
import inspect
import uuid

def logGetTraceInfo():
    callerframerecord = inspect.stack()[2]    # 0 represents this line
    frame = callerframerecord[0]
    info = inspect.getframeinfo(frame)
    return info

# Log Level
FATAL   = 1
ERROR   = 2
WARNING = 3
INFO    = 4
VERBOSE = 5
DEBUG   = VERBOSE

def setLevel(level):
    pysetlevel(level)

def setContext(context):
    pysetcontext(context)

def setFilters(filters):
    pysetfilters(filters)

def _printToString(*args):
    return ' '.join(str(x) for x in args)

class PyLogger:
    def __init__(self, category):
        self.category = category

    def fatal(self, *args):
        info = logGetTraceInfo()
        pylog(FATAL, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def error(self, *args):
        info = logGetTraceInfo()
        pylog(ERROR, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def warning(self, *args):
        info = logGetTraceInfo()
        pylog(WARNING, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def info(self, *args):
        info = logGetTraceInfo()
        pylog(INFO, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def verbose(self, *args):
        info = logGetTraceInfo()
        pylog(VERBOSE, self.category, _printToString(*args), info.filename, info.function, info.lineno)

    def debug(self, *args):
        self.verbose(*args)

def getLogger( name):
    return PyLogger(name)

def logSilent(cat, *args):
    info = logGetTraceInfo()
    pylog(0, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logFatal(cat, *args):
    info = logGetTraceInfo()
    pylog(FATAL, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logError(cat, *args):
    info = logGetTraceInfo()
    pylog(ERROR, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logWarning(cat, *args):
    info = logGetTraceInfo()
    pylog(WARNING, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logInfo(cat, *args):
    info = logGetTraceInfo()
    pylog(INFO, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logVerbose(cat, *args):
    info = logGetTraceInfo()
    pylog(VERBOSE, cat, _printToString(*args), info.filename, info.function, info.lineno)

def logDebug(cat, *args):
    logVerbose(cat, *args)
{'fraction_non_alphanumeric': 0.12905632226781052, 'fraction_numerical': 0.007086907870197687, 'mean_word_length': 3.9842007434944238, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4783123', 'n_tokens_mistral': 1798, 'n_tokens_neox': 1772, 'n_words': 440}