Skip to content

Commit da28d0b

Browse files
authored
Merge pull request #666 from nicozanf/errorlog
Rename logfile command option to errorlog
2 parents 32256e6 + 8b319ef commit da28d0b

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ Launch Arguments
100100
[default: lazy]
101101
--ssl_cert PATH SSL certificate file for HTTPS
102102
--ssl_key PATH SSL key file for HTTPS
103+
--errorlog TEXT Where to send error logs
104+
(:stdout|:stderr|tickets_only|{filename})
105+
[default: :stderr]
103106
-help, -h, --help Show this message and exit.
104107
105108

docs/chapter-03.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ running it without any argument
278278

279279
# py4web
280280

281-
.. FIXME: next image must be updated
282281

283282
.. image:: images/command.png
284283
:class: with-shadow
@@ -370,6 +369,9 @@ This currently gives an error on binaries installations and from source installa
370369

371370
--ssl_cert PATH SSL certificate file for HTTPS
372371
--ssl_key PATH SSL key file for HTTPS
372+
--errorlog TEXT Where to send error logs
373+
(:stdout|:stderr|tickets_only|{filename})
374+
[default: :stderr]
373375
-help, -h, --help Show this message and exit.
374376

375377

py4web/core.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,15 +1008,17 @@ def get_error_snapshot(depth=5):
10081008
"""Return a dict describing a given traceback (based on cgitb.text)."""
10091009

10101010
tb = traceback.format_exc()
1011-
logfile = os.environ.get("PY4WEB_LOGFILE")
1012-
if logfile:
1011+
errorlog = os.environ.get("PY4WEB_ERRORLOG")
1012+
if errorlog:
10131013
msg = f"[{datetime.datetime.now().isoformat()}]: {tb}\n"
1014-
if logfile == ':stderr':
1014+
if errorlog == ':stderr':
10151015
sys.stderr.write(msg)
1016-
elif logfile == ':stdout':
1016+
elif errorlog == ':stdout':
10171017
sys.stdout.write(msg)
1018+
elif errorlog == 'tickets_only':
1019+
pass
10181020
else:
1019-
with portalocker.Lock(logfile, "a", timeout=2) as fp:
1021+
with portalocker.Lock(errorlog, "a", timeout=2) as fp:
10201022
fp.write(msg)
10211023

10221024
etype, evalue, etb = sys.exc_info()
@@ -1895,7 +1897,11 @@ def new_app(apps_folder, app_name, yes, scaffold_zip):
18951897
"--ssl_cert", type=click.Path(exists=True), help="SSL certificate file for HTTPS"
18961898
)
18971899
@click.option("--ssl_key", type=click.Path(exists=True), help="SSL key file for HTTPS")
1898-
@click.option("--logfile", default="", help="Where to send error logs (:stdout/:stderr/{filename})")
1900+
@click.option("--errorlog",
1901+
default=":stderr",
1902+
help="Where to send error logs (:stdout|:stderr|tickets_only|{filename})",
1903+
show_default=True,
1904+
)
18991905
def run(**kwargs):
19001906
"""Run all the applications on apps_folder"""
19011907
install_args(kwargs)

0 commit comments

Comments
 (0)