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