# 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
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nuka. If not, see <http://www.gnu.org/licenses/>.




class HostLogger(logging.Logger):
    """Logger for a host that can log to a file and stdout at different
    levels"""

    def __init__(self, host):
        self.host = host
        stream_level = nuka.config['log']['levels']['stream_level']
        file_level = nuka.config['log']['levels']['file_level']
        super().__init__(host, max(stream_level, file_level))
        if stream_level is not None:
            if nuka.config['log']['quiet']:
                filename = nuka.config['log']['stdout']
                self.addHandler(HostFileHandler(host, level=stream_level,
                                                filename=filename))
            else:
                self.addHandler(HostStreamHandler(host, level=stream_level))
        self.addHandler(HostFileHandler(host, level=file_level))

    def changed(self, *args, **kwargs):
        self.log(CHANGED, *args, **kwargs)

    def __call__(self, msg, *args, **kwargs):

# 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

# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with nuka. If not, see <http://www.gnu.org/licenses/>.




class HostLogger(logging.Logger):
    """Logger for a host that can log to a file and stdout at different
    levels"""

    def __init__(self, host):
        self.host = host
        stream_level = nuka.config['log']['levels']['stream_level']
        file_level = nuka.config['log']['levels']['file_level']
        super().__init__(host, max(stream_level, file_level))
        if stream_level is not None:
            if nuka.config['log']['quiet']:
                filename = nuka.config['log']['stdout']
                self.addHandler(HostFileHandler(host, level=stream_level,
                                                filename=filename))
            else:
                self.addHandler(HostStreamHandler(host, level=stream_level))
        self.addHandler(HostFileHandler(host, level=file_level))

    def changed(self, *args, **kwargs):
        self.log(CHANGED, *args, **kwargs)

    def __call__(self, msg, *args, **kwargs):

        self.log(LOG, msg, *args, **kwargs)