mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: Ignore failure to strftime log entries
This commit is contained in:
parent
e903aabf0c
commit
affd7be313
@ -8,6 +8,7 @@ import errno
|
||||
import hashlib
|
||||
import os
|
||||
import struct
|
||||
import time
|
||||
import uuid
|
||||
from collections import namedtuple
|
||||
from functools import wraps
|
||||
@ -21,7 +22,7 @@ from calibre.srv.errors import HTTPSimpleResponse
|
||||
from calibre.srv.http_request import HTTPRequest, read_headers
|
||||
from calibre.srv.loop import WRITE
|
||||
from calibre.srv.utils import (
|
||||
HTTP1, HTTP11, Cookie, MultiDict, fast_now_strftime, get_translator_for_lang,
|
||||
HTTP1, HTTP11, Cookie, MultiDict, get_translator_for_lang,
|
||||
http_date, socket_errors_socket_closed, sort_q_values
|
||||
)
|
||||
from calibre.utils.monotonic import monotonic
|
||||
@ -549,9 +550,13 @@ class HTTPConnection(HTTPRequest):
|
||||
ff = self.forwarded_for
|
||||
if ff:
|
||||
ff = '[%s] ' % ff
|
||||
try:
|
||||
ts = time.strftime('%d/%b/%Y:%H:%M:%S %z')
|
||||
except Exception:
|
||||
ts = 'strftime() failed'
|
||||
line = '{} port-{} {}{} {} "{}" {} {}'.format(
|
||||
self.remote_addr, self.remote_port, ff or '', username or '-',
|
||||
fast_now_strftime('%d/%b/%Y:%H:%M:%S %z'),
|
||||
ts,
|
||||
force_unicode(self.request_line or '', 'utf-8'),
|
||||
status_code, ('-' if response_size is None else response_size))
|
||||
self.access_log(line)
|
||||
|
@ -4,7 +4,7 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import errno, socket, os, time
|
||||
import errno, socket, os
|
||||
from email.utils import formatdate
|
||||
from operator import itemgetter
|
||||
|
||||
@ -465,7 +465,3 @@ def get_use_roman():
|
||||
from calibre.gui2 import config
|
||||
_use_roman = config['use_roman_numerals_for_series_number']
|
||||
return _use_roman
|
||||
|
||||
|
||||
def fast_now_strftime(fmt):
|
||||
return as_unicode(time.strftime(fmt), errors='replace')
|
||||
|
Loading…
x
Reference in New Issue
Block a user