Allow setting a logfile and a loglevel in tileserver
@@ -17,11 +17,16 @@ from c3nav.mapdata.utils.cache import CachePackage
from c3nav.mapdata.utils.tiles import (build_access_cache_key, build_base_cache_key, build_tile_etag, get_tile_bounds,
parse_tile_access_cookie)
-logging.basicConfig(level=logging.DEBUG if os.environ.get('C3NAV_DEBUG') else logging.INFO,
+loglevel = logging.DEBUG if os.environ.get('C3NAV_DEBUG') else os.environ.get("LOGLEVEL","INFO")
+
+logging.basicConfig(level=loglevel,
format='[%(asctime)s] [%(process)s] [%(levelname)s] %(name)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S %z')
+
logger = logging.getLogger('c3nav')
+if os.environ.get('C3NAV_LOGFILE'):
+ logging.basicConfig(filename=os.environ['C3NAV_LOGFILE'])
class TileServer:
def __init__(self):
