(self, log, output, fmt, stream=None)
| 417 | return h |
| 418 | |
| 419 | def _set_handler(self, log, output, fmt, stream=None): |
| 420 | # remove previous gunicorn log handler |
| 421 | h = self._get_gunicorn_handler(log) |
| 422 | if h: |
| 423 | log.handlers.remove(h) |
| 424 | |
| 425 | if output is not None: |
| 426 | if output == "-": |
| 427 | h = logging.StreamHandler(stream) |
| 428 | else: |
| 429 | util.check_is_writable(output) |
| 430 | h = logging.FileHandler(output) |
| 431 | # make sure the user can reopen the file |
| 432 | try: |
| 433 | os.chown(h.baseFilename, self.cfg.user, self.cfg.group) |
| 434 | except OSError: |
| 435 | # it's probably OK there, we assume the user has given |
| 436 | # /dev/null as a parameter. |
| 437 | pass |
| 438 | |
| 439 | h.setFormatter(fmt) |
| 440 | h._gunicorn = True |
| 441 | log.addHandler(h) |
| 442 | |
| 443 | def _set_syslog_handler(self, log, cfg, fmt, name): |
| 444 | # setup format |
no test coverage detected