Make better use of vlogging.
This commit is contained in:
parent
7c1b6b293d
commit
23f9a5427f
2 changed files with 9 additions and 18 deletions
|
@ -1840,7 +1840,6 @@ class PhotoDB(
|
||||||
*,
|
*,
|
||||||
create=True,
|
create=True,
|
||||||
ephemeral=False,
|
ephemeral=False,
|
||||||
log_level=vlogging.NOTSET,
|
|
||||||
skip_version_check=False,
|
skip_version_check=False,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
|
@ -1890,7 +1889,6 @@ class PhotoDB(
|
||||||
|
|
||||||
# LOGGING
|
# LOGGING
|
||||||
self.log = vlogging.getLogger(f'{__name__}:{self.data_directory.absolute_path}')
|
self.log = vlogging.getLogger(f'{__name__}:{self.data_directory.absolute_path}')
|
||||||
self.log.setLevel(log_level)
|
|
||||||
|
|
||||||
# DATABASE
|
# DATABASE
|
||||||
if self.ephemeral:
|
if self.ephemeral:
|
||||||
|
|
|
@ -6,21 +6,16 @@ python etiquette_flask_dev.py [port]
|
||||||
'''
|
'''
|
||||||
import gevent.monkey; gevent.monkey.patch_all()
|
import gevent.monkey; gevent.monkey.patch_all()
|
||||||
|
|
||||||
import logging
|
|
||||||
handler = logging.StreamHandler()
|
|
||||||
log_format = '{levelname}:etiquette.{module}.{funcName}: {message}'
|
|
||||||
handler.setFormatter(logging.Formatter(log_format, style='{'))
|
|
||||||
logging.getLogger().addHandler(handler)
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import gevent.pywsgi
|
import gevent.pywsgi
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from voussoirkit import pathclass
|
from voussoirkit import pathclass
|
||||||
from voussoirkit import pipeable
|
|
||||||
from voussoirkit import vlogging
|
from voussoirkit import vlogging
|
||||||
|
|
||||||
|
log = vlogging.getLogger(__name__, 'etiquette_flask_dev')
|
||||||
|
|
||||||
import etiquette
|
import etiquette
|
||||||
import backend
|
import backend
|
||||||
|
|
||||||
|
@ -28,7 +23,6 @@ site = backend.site
|
||||||
site.debug = True
|
site.debug = True
|
||||||
|
|
||||||
HTTPS_DIR = pathclass.Path(__file__).parent.with_child('https')
|
HTTPS_DIR = pathclass.Path(__file__).parent.with_child('https')
|
||||||
LOG_LEVEL = vlogging.NOTSET
|
|
||||||
|
|
||||||
####################################################################################################
|
####################################################################################################
|
||||||
|
|
||||||
|
@ -58,21 +52,22 @@ def etiquette_flask_launch(
|
||||||
site.localhost_only = True
|
site.localhost_only = True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
backend.common.init_photodb(path=pathclass.cwd(), log_level=LOG_LEVEL)
|
backend.common.init_photodb(path=pathclass.cwd())
|
||||||
except etiquette.exceptions.NoClosestPhotoDB as exc:
|
except etiquette.exceptions.NoClosestPhotoDB as exc:
|
||||||
pipeable.stderr(exc.error_message)
|
log.error(exc.error_message)
|
||||||
pipeable.stderr('Try `etiquette_cli.py init` to create the database.')
|
log.error('Try `etiquette_cli.py init` to create the database.')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
message = f'Starting server on port {port}, pid={os.getpid()}.'
|
message = f'Starting server on port {port}, pid={os.getpid()}.'
|
||||||
if use_https:
|
if use_https:
|
||||||
message += ' (https)'
|
message += ' (https)'
|
||||||
print(message)
|
log.info(message)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
http.serve_forever()
|
http.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
log.info('Goodbye')
|
||||||
|
return 0
|
||||||
|
|
||||||
def etiquette_flask_launch_argparse(args):
|
def etiquette_flask_launch_argparse(args):
|
||||||
return etiquette_flask_launch(
|
return etiquette_flask_launch(
|
||||||
|
@ -81,10 +76,8 @@ def etiquette_flask_launch_argparse(args):
|
||||||
use_https=args.use_https,
|
use_https=args.use_https,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@vlogging.main_decorator
|
||||||
def main(argv):
|
def main(argv):
|
||||||
global LOG_LEVEL
|
|
||||||
(LOG_LEVEL, argv) = vlogging.get_level_by_argv(argv)
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
parser.add_argument('port', nargs='?', type=int, default=5000)
|
parser.add_argument('port', nargs='?', type=int, default=5000)
|
||||||
|
|
Loading…
Reference in a new issue