Create log dir if it does not already exist

This commit is contained in:
Kovid Goyal 2017-05-10 16:05:11 +05:30
parent 13906d2fd6
commit 1a9bc089f2
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -3,6 +3,7 @@
# License: GPLv3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import absolute_import, division, print_function, unicode_literals
import errno
import os
from threading import Thread
@ -12,8 +13,8 @@ from calibre.srv.bonjour import BonJour
from calibre.srv.handler import Handler
from calibre.srv.http_response import create_http_handler
from calibre.srv.loop import ServerLoop
from calibre.srv.utils import RotatingLog
from calibre.srv.opts import server_config
from calibre.srv.utils import RotatingLog
def log_paths():
@ -30,6 +31,11 @@ class Server(object):
def __init__(self, library_broker, notify_changes):
opts = server_config()
lp, lap = log_paths()
try:
os.makedirs(cache_dir())
except EnvironmentError as err:
if err.errno != errno.EEXIST:
raise
log_size = opts.max_log_size * 1024 * 1024
log = RotatingLog(lp, max_size=log_size)
access_log = RotatingLog(lap, max_size=log_size)