Fix logging.
This commit is contained in:
parent
5f74d80267
commit
d2148dfafb
|
@ -35,13 +35,13 @@ from selenium.common.exceptions import (
|
|||
# TODO: read it from configuration.
|
||||
RETRIES = 3
|
||||
|
||||
logging.basicConfig(
|
||||
level=os.environ.get("BOTZ_LOGLEVEL", logging.INFO),
|
||||
format="%(levelname)s: [%(name)s] -> %(message)s",
|
||||
)
|
||||
|
||||
m_logger = logging.getLogger(__name__)
|
||||
m_logger.debug("Init at debug")
|
||||
log_fmt = logging.Formatter("%(levelname)s: [%(name)s] -> %(message)s")
|
||||
console = logging.StreamHandler(stream=sys.stdout)
|
||||
console.setFormatter(log_fmt)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.addHandler(console)
|
||||
logger.setLevel(os.environ.get("BOTZ_LOGLEVEL", logging.INFO))
|
||||
logger.debug("Init at debug")
|
||||
|
||||
|
||||
def safely(retries: int = 0) -> T.Callable:
|
||||
|
@ -86,9 +86,9 @@ def is_present(
|
|||
_now = datetime.now()
|
||||
_elapsed = timedelta(seconds=0)
|
||||
while _elapsed < timeout:
|
||||
m_logger.debug("Not yet present: %s", xpath)
|
||||
logger.debug("Not yet present: %s", xpath)
|
||||
if _is_present(driver, xpath):
|
||||
m_logger.debug("Present: %s", xpath)
|
||||
logger.debug("Present: %s", xpath)
|
||||
return True
|
||||
time.sleep(0.5)
|
||||
_elapsed = datetime.now() - _now
|
||||
|
|
|
@ -17,6 +17,8 @@ from bot_z.utils import Fifo, PLifo, cmd_marshal
|
|||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(os.environ.get("BOTZ_LOGLEVEL", logging.INFO))
|
||||
sh = logging.StreamHandler(stream=sys.stdout)
|
||||
cli_filter = logging.Filter(__name__)
|
||||
sh.addFilter(cli_filter)
|
||||
sh.setFormatter(logging.Formatter("%(message)s"))
|
||||
logger.addHandler(sh)
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import logging.handlers
|
|||
import os
|
||||
import queue
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
import typing as T
|
||||
|
||||
|
@ -19,16 +20,18 @@ import daemon
|
|||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
level=os.environ.get("BOTZ_LOGLEVEL", logging.INFO),
|
||||
format="%(levelname)s: [%(name)s] -> %(message)s",
|
||||
)
|
||||
daemon_format = logging.Formatter("%(levelname)s: [%(name)s] -> %(message)s")
|
||||
|
||||
console = logging.StreamHandler(stream=sys.stdout)
|
||||
console.setFormatter(daemon_format)
|
||||
console.addFilter(logging.Filter(__name__))
|
||||
|
||||
syslog = logging.handlers.SysLogHandler(address="/dev/log")
|
||||
syslog.setFormatter(logging.Formatter("%(levelname)s: [%(name)s] -> %(message)s"))
|
||||
syslog.setFormatter(daemon_format)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(os.environ.get("BOTZ_LOGLEVEL", logging.INFO))
|
||||
logger.addHandler(console)
|
||||
logger.addHandler(syslog)
|
||||
logger.debug("Init at debug")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user