Configuring and Using Python 3.5.2 Log

I am new to python and trying to set up a registrar in my simple application.

This is the structure of the application:

 - checker
      - checking
         - proxy_checker.py
      - custom_threading
         - __init__.py
         - executor_my.py
         - long_task.py
      - tests
      - __init__.py
      - logging_config.ini
      - main.py

I am trying to configure a file configured on a registrar in the main module checker/__init__.py :

from logging.config import fileConfig

fileConfig('logging_config.ini')

logging_config.ini

[loggers]
keys=root

[handlers]
keys=stream_handler

[formatters]
keys=formatter

[logger_root]
level=DEBUG
handlers=stream_handler

[handler_stream_handler]
class=StreamHandler
level=DEBUG
formatter=formatter
args=(sys.stderr,)

[formatter_formatter]
format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s

and use it in /checker/custom_threading/exector_my.py:

import concurrent.futures
import logging

from custom_threading.long_task import LongTask


class MyExecutor(object):
    logger = logging.getLogger(__name__)
    _executor = concurrent.futures.ThreadPoolExecutor(max_workers=500)

    def __init__(self, thread_count, task):
        self._thread_count = thread_count
        self._task = LongTask(task)
        pass

    def start(self):
        self.logger.debug("Launching with thread count: " + str(self._thread_count))

*more irrelevant code*

tried using logger.info/logger.debug. for both options I get no errors and nothing is written to the console . What am I doing wrong?

PS maybe it’s also useful that I run it on Win 10 x64

+4
source share
1 answer

My (, :-) , script - python checker/main.py, __init__.py .

, : __init__.py ?

, , fileConfig() getLogger() ( ). - - main.py MyExecutor.__init__().

+1

Source: https://habr.com/ru/post/1657381/


All Articles