Commit 9a6df5fd authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Use utils.debug in kamaki client

parent 4b1a745b
#!/usr/bin/env python
from commissioning import Callpoint, CallError
from commissioning.utils.debug import debug
from kamaki.clients import Client
import logging
from json import loads as json_loads, dumps as json_dumps
_logger = None
def init_logger_file(name, level='DEBUG'):
logger = logging.getLogger(name)
handler = logging.FileHandler(name + '.log')
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
level = getattr(logging, level, logging.DEBUG)
logger.setLevel(level)
global _logger
_logger = logger
return logger
def init_logger_stderr(name, level='DEBUG'):
logger = logging.getLogger(name)
from sys import stderr
handler = logging.StreamHandler(stderr)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
level = getattr(logging, level, logging.DEBUG)
logger.setLevel(level)
global _logger
_logger = logger
return logger
def debug(fmt, *args):
global _logger
if _logger is None:
init_logger_stderr('logger')
_logger.setLevel(logging.DEBUG)
_logger.debug(fmt % args)
class Kamaki_plugin(Callpoint):
def __init__(self, base_url, token):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment