This repository has been archived on 2025-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
Files
fbchat/fbchat/_core.py
Mads Marquart d3a0ffc478 Fix logging
- Following advice here: https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
- Renamed the logger: client -> fbchat
- Remove logging_level init parameter from Client
- Use print instead of log.info in examples
2019-08-28 22:27:29 +02:00

24 lines
631 B
Python

import logging
import aenum
log = logging.getLogger("fbchat")
class Enum(aenum.Enum):
"""Used internally by ``fbchat`` to support enumerations"""
def __repr__(self):
# For documentation:
return "{}.{}".format(type(self).__name__, self.name)
@classmethod
def _extend_if_invalid(cls, value):
try:
return cls(value)
except ValueError:
log.warning(
"Failed parsing {.__name__}({!r}). Extending enum.".format(cls, value)
)
aenum.extend_enum(cls, "UNKNOWN_{}".format(value).upper(), value)
return cls(value)