12345678910 |
- import logging
- import os
- class MPFileLogHandler(logging.Handler):
- def __init__(self, file_path):
- self._fd = os.open(file_path, os.O_WRONLY | os.O_CREAT | os.O_APPEND)
- logging.Handler.__init__(self)
- def emit(self, record):
- msg = "{}\n".format(self.format(record))
- os.write(self._fd, msg.encode('utf-8'))
|