# Path: nuka/utils.py
# LOG = 60
# 
# Path: nuka/utils.py
# CHANGED = logging.WARNING + 1


import logging
import sys
import os
import nuka
from nuka.utils import LOG
from nuka.utils import CHANGED
        if not os.path.isdir(os.path.dirname(self.filename)):
            os.makedirs(os.path.dirname(self.filename))
        super().__init__(self.filename, 'w')
        fmt = nuka.config['log']['formats']['default']
        self.setFormatter(logging.Formatter(fmt))
        self.setLevel(level)

    def rollover(self):
        for i in range(9 - 1, 0, -1):
            sfn = "%s.%d" % (self.filename, i)
            dfn = "%s.%d" % (self.filename, i + 1)
            if os.path.exists(sfn):
                if os.path.exists(dfn):
                    os.remove(dfn)
                os.rename(sfn, dfn)
        dfn = self.filename + ".1"
        if os.path.exists(dfn):
            os.remove(dfn)
        if os.path.exists(self.filename):
            os.rename(self.filename, dfn)


class HostStreamHandler(logging.StreamHandler):

    reset = "\033[0m"

    def __init__(self, host, level):
        self.host = host
        super().__init__(sys.stdout)
        fmt = nuka.config['log']['formats']['host'].format(host)

# Path: nuka/utils.py
# LOG = 60
# 
# Path: nuka/utils.py
# CHANGED = logging.WARNING + 1


# Path: nuka/log.py
import logging
import sys
import os
import nuka
from nuka.utils import LOG
from nuka.utils import CHANGED

        if not os.path.isdir(os.path.dirname(self.filename)):
            os.makedirs(os.path.dirname(self.filename))
        super().__init__(self.filename, 'w')
        fmt = nuka.config['log']['formats']['default']
        self.setFormatter(logging.Formatter(fmt))
        self.setLevel(level)

    def rollover(self):
        for i in range(9 - 1, 0, -1):
            sfn = "%s.%d" % (self.filename, i)
            dfn = "%s.%d" % (self.filename, i + 1)
            if os.path.exists(sfn):
                if os.path.exists(dfn):
                    os.remove(dfn)
                os.rename(sfn, dfn)
        dfn = self.filename + ".1"
        if os.path.exists(dfn):
            os.remove(dfn)
        if os.path.exists(self.filename):
            os.rename(self.filename, dfn)


class HostStreamHandler(logging.StreamHandler):

    reset = "\033[0m"

    def __init__(self, host, level):
        self.host = host
        super().__init__(sys.stdout)
        fmt = nuka.config['log']['formats']['host'].format(host)

        self.setFormatter(logging.Formatter(fmt))