本文整理汇总了Python中logger.get方法的典型用法代码示例。如果您正苦于以下问题:Python logger.get方法的具体用法?Python logger.get怎么用?Python logger.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger
的用法示例。
在下文中一共展示了logger.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, filename=None, default_verbose=0):
"""
Constructs a logger with optional log file output.
Args:
filename: optional log file output. If None, nothing will be
written to file
"""
now = datetime.datetime.now()
self.verbose_thresh = int(os.environ.get("VERBOSE", 0))
self.default_verbose = default_verbose
if filename is not None:
self.filename = filename
dirname = os.path.dirname(self.filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
open(self.filename, "w").close()
self.info("Log written to {}".format(os.path.abspath(self.filename)))
else:
self.filename = None
pass
示例2: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, filename=None, default_verbose=0):
"""
Constructs a logger with optional log file output.
Args:
filename: optional log file output. If None, nothing will be
written to file
"""
now = datetime.datetime.now()
self.verbose_thresh = int(os.environ.get("VERBOSE", 0))
self.default_verbose = default_verbose
if filename is not None:
self.filename = filename
dirname = os.path.dirname(self.filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
open(self.filename, "w").close()
self.info("Log written to {}".format(os.path.abspath(self.filename)))
else:
self.filename = None
pass
示例3: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, filename=None, default_verbose=0):
"""
Constructs a logger with optional log file output.
Args:
filename: optional log file output. If None, nothing will be
written to file
"""
now = datetime.datetime.now()
self.verbose_thresh = int(os.environ.get('VERBOSE', 0))
self.default_verbose = default_verbose
if filename is not None:
self.filename = filename
dirname = os.path.dirname(self.filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
open(self.filename, 'w').close()
self.info('Log written to {}'.format(os.path.abspath(self.filename)))
else:
self.filename = None
pass
示例4: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, filename=None):
"""
Constructs a logger with optional log file output.
Args:
filename: optional log file output. If None, nothing will be
written to file
"""
now = datetime.datetime.now()
self.verbose_thresh = os.environ.get('VERBOSE', 0)
if filename is not None:
self.filename = \
'{}-{:04d}{:02d}{:02d}-{:02d}{:02d}{:02d}.log'.format(
filename,
now.year, now.month, now.day,
now.hour, now.minute, now.second)
dirname = os.path.dirname(self.filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
open(self.filename, 'w').close()
self.info('Log written to {}'.format(
os.path.abspath(self.filename)))
else:
self.filename = None
pass
示例5: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, filename=None, default_verbose=0):
"""
Constructs a logger with optional log file output.
Args:
filename: optional log file output. If None, nothing will be
written to file
"""
now = datetime.datetime.now()
self.verbose_thresh = int(os.environ.get('VERBOSE', 0))
self.default_verbose = default_verbose
if filename is not None:
self.filename = filename
dirname = os.path.dirname(self.filename)
if not os.path.exists(dirname):
os.makedirs(dirname)
open(self.filename, 'w').close()
self.info('Log written to {}'.format(os.path.abspath(self.filename)))
else:
self.filename = None
pass
示例6: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, folder, model_opt=None, data_opt=None):
if not os.path.exists(folder):
os.makedirs(folder)
self.folder = folder
self.log = logger.get()
self.tf_saver = None
if model_opt is not None:
self.save_opt(os.path.join(folder, kModelOptFilename), model_opt)
if data_opt is not None:
self.save_opt(os.path.join(folder, kDatasetOptFilename), data_opt)
示例7: get
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def get(fname=None):
"""
Returns a logger instance, with optional log file output.
"""
global log
if log is not None and fname is None:
return log
# fname = os.environ.get("LOGTO", None)
# if fname is None:
# fname = default_fname
else:
log = Logger(fname)
return log
示例8: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, q, batch_iter):
super(BatchProducer, self).__init__()
threading.Thread.__init__(self)
self.q = q
self.batch_iter = batch_iter
self.log = logger.get()
self._stop = threading.Event()
self.daemon = True
示例9: run
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def run(self):
while not self.stopped():
try:
self.q.get(False)
self.q.task_done()
except queue.Empty:
pass
示例10: next
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def next(self):
if self._stopped:
raise StopIteration
self.scan(do_print=(self.counter % self.log_queue == 0))
if self.counter % self.log_queue == 0:
self.counter = 0
batch = self.q.get()
self.q.task_done()
self.counter += 1
while batch is None:
self.info("Got an empty batch. Ending iteration.")
self.relaunch = False
try:
batch = self.q.get(False)
self.q.task_done()
qempty = False
except queue.Empty:
qempty = True
pass
if qempty:
self.info("Queue empty. Scanning for alive thread.")
# Scan for alive thread.
found_alive = False
for ff in self.fetchers:
if ff.is_alive():
found_alive = True
break
self.info("No alive thread found. Joining.")
# If no alive thread, join all.
if not found_alive:
for ff in self.fetchers:
ff.join()
self._stopped = True
raise StopIteration
else:
self.info("Got another batch from the queue.")
return batch
示例11: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, folder, name):
if not os.path.exists(folder):
os.makedirs(folder)
self.folder = folder
self.log = logger.get()
self.fname = os.path.join(folder, name + '.yaml')
示例12: get
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def get(fname=None):
"""
Returns a logger instance, with optional log file output.
"""
global log
if log is not None and fname is None:
return log
# fname = os.environ.get('LOGTO', None)
# if fname is None:
# fname = default_fname
else:
log = Logger(fname)
return log
示例13: get
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def get(default_fname=None):
"""
Returns a logger instance, with optional log file output.
"""
global log
if log is not None:
return log
fname = os.environ.get('LOGTO', None)
if fname is None:
fname = default_fname
log = Logger(fname)
return log
示例14: __init__
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def __init__(self, config):
self._mqtt_callbacks = []
self._config_commands = []
self._update_commands = []
self._scheduler = BackgroundScheduler(timezone=utc)
self._daemons = []
self._config = config
self._command_timeout = config.get("command_timeout", DEFAULT_COMMAND_TIMEOUT)
示例15: _publish_config
# 需要导入模块: import logger [as 别名]
# 或者: from logger import get [as 别名]
def _publish_config(self, mqtt):
for command in self._config_commands:
messages = command.execute()
for msg in messages:
msg.topic = "{}/{}".format(
self._config["sensor_config"].get("topic", "homeassistant"),
msg.topic,
)
msg.retain = self._config["sensor_config"].get("retain", True)
mqtt.publish(messages)