Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying to Log with ERROR level and this bug: #1

Open
ohld opened this issue Jun 21, 2019 · 1 comment
Open

Trying to Log with ERROR level and this bug: #1

ohld opened this issue Jun 21, 2019 · 1 comment

Comments

@ohld
Copy link

ohld commented Jun 21, 2019

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/handlers.py", line 1478, in _monitor
    self.handle(record)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/handlers.py", line 1461, in handle
    handler.handle(record)
  File "/usr/local/lib/python3.7/site-packages/python_telegram_logger/handlers.py", line 109, in handle
    self.emit(record)
  File "/usr/local/lib/python3.7/site-packages/python_telegram_logger/handlers.py", line 116, in emit
    mode=self.formatter.MODE,
AttributeError: 'Formatter' object has no attribute 'MODE'```
@ohld
Copy link
Author

ohld commented Jun 21, 2019

Problem was in my config file: your library doesn't support the formatter:

log_config = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        'simple': {
            'format': '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
        }
    },
    "handlers": {
        "telegram": {
            "class": "python_telegram_logger.Handler",
            "token": Config.TALEGRAM_TOKEN,
            "chat_ids": [Config.TELEGRAM_MONITORING_CHAT_ID],
            # "formatter": "simple",
            "level": "WARNING",
        },
         "console": {
            "class": "logging.StreamHandler",
            "formatter": "simple",
            "level": "INFO",
        },
    },
    "root": {
        "handlers": ["telegram", "console"],
        "level": "INFO",
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant