Exemple #1
0
 def _new_logger(cls,
                 format="[{name}][{levelname}] {message}",
                 style="{",
                 **params):
     output = StringIO()
     logger.basicConfig(stream=output, format=format, style=style, **params)
     return logging.getLogger("streamlink.test"), output
Exemple #2
0
def setup_logging(stream=sys.stdout, level="info"):
    logger.basicConfig(stream=stream,
                       level=level,
                       style="{",
                       format=("[{asctime}]" if level == "trace" else "") +
                       "[{name}][{levelname}] {message}",
                       datefmt="%H:%M:%S" +
                       (".%f" if level == "trace" else ""))
Exemple #3
0
def setup_logger_and_console(stream=sys.stdout,
                             filename=None,
                             level="info",
                             json=False):
    global console

    if filename == "-":
        if not os.path.isdir(LOG_DIR):
            os.makedirs(LOG_DIR)
        filename = os.path.join(
            LOG_DIR,
            datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S.log"))
    elif filename:
        filename = os.path.expanduser(filename)
        head = os.path.dirname(filename)
        if head and not os.path.isdir(head):
            os.makedirs(head)

    streamhandler = logger.basicConfig(
        stream=stream,
        filename=filename,
        level=level,
        style="{",
        format=("[{asctime},{msecs:03.0f}]" if level == "trace" else "") +
        "[{name}][{levelname}] {message}",
        datefmt="%H:%M:%S")

    console = ConsoleOutput(streamhandler.stream, streamlink, json)
def setup_logger_and_console(stream=sys.stdout,
                             filename=None,
                             level="info",
                             json=False):
    global console

    if filename == "-":
        filename = LOG_DIR / datetime.datetime.now().strftime(
            "%Y-%m-%d_%H-%M-%S.log")
    elif filename:
        filename = Path(filename).expanduser().resolve()

    if filename:
        filename.parent.mkdir(parents=True, exist_ok=True)

    streamhandler = logger.basicConfig(
        stream=stream,
        filename=filename,
        level=level,
        style="{",
        format=("[{asctime}]" if level == "trace" else "") +
        "[{name}][{levelname}] {message}",
        datefmt="%H:%M:%S" + (".%f" if level == "trace" else ""))

    console = ConsoleOutput(streamhandler.stream, json)
Exemple #5
0
def setup_logging(stream=sys.stdout, level="info"):
    logger.basicConfig(stream=stream, level=level, format="[{name}][{levelname}] {message}", style="{")
Exemple #6
0
def setup_logging(stream=sys.stdout, level='debug'):
    fmt = ("[{asctime},{msecs:0.0f}]" if level == "trace" else "") + "[{name}][{levelname}] {message}"
    logger.basicConfig(stream=stream, level=level,
                       format=fmt, style="{",
                       datefmt="%H:%M:%S")
Exemple #7
0
def setup_logging(stream=sys.stdout, level="info"):
    fmt = ("[{asctime},{msecs:0.0f}]" if level == "trace" else "") + "[{name}][{levelname}] {message}"
    logger.basicConfig(stream=stream, level=level,
                       format=fmt, style="{",
                       datefmt="%H:%M:%S")