justpy icon indicating copy to clipboard operation
justpy copied to clipboard

justpy should log to a dedicated logger

Open eudoxos opened this issue 4 years ago • 4 comments

Justpy currently uses logging.{info,debug} which puts messages to the root logger. Would you accept a PR with config variable LOGGING_LOGGER (similar to already existing LOGGING_LEVEL) and define JustPy.log as the logger object to use everywhere? Ocurrences of logging.info(...) would be simply replaced by JustPy.log.info(...). The intention is to set logging verbosity for JustPy separately from other loggers.

eudoxos avatar Nov 30 '20 17:11 eudoxos

Agreed. I started looking at OpenTracing to do this but haven´t come far enough as I needed to sort out some other things first. There´s a project that att OpenTracing to Starlette here that might be of help. https://github.com/acidjunk/starlette-opentracing

From the docs it look like it should be as easy as using Tortoise ORM in with Starlette/JustPy as it inject itself as a Starlette Middleware.

swevm avatar Nov 30 '20 17:11 swevm

When you setup your service to run gunicorn, why not set it to log to whatever file you want?

[Unit]
Description=gunicorn daemon
#Requires=gunicorn.socket
After=network.target

[Service]
Type=notify
User=apache
Group=apache
RuntimeDirectory=gunicorn
WorkingDirectory=/path_to_your_project/
Environment=PYTHONUNBUFFERED=TRUE
ExecStart=/usr/local/bin/pipenv run gunicorn -k uvicorn.workers.UvicornWorker -b 127.0.0.1:8000 asgi:app --capture-output --log-level debug --error-logfile /path_to_your_project/error.log, --log-file /path_to_your_project/access.log
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true

[Install]
WantedBy=multi-user.target

knoxvilledatabase avatar Nov 30 '20 18:11 knoxvilledatabase

Would you accept a PR with config variable LOGGING_LOGGER (similar to already existing LOGGING_LEVEL) and define JustPy.log as the logger object to use everywhere?

Yes, if I recall correctly other people wanted this feature also

elimintz avatar Nov 30 '20 20:11 elimintz

See #178 .

eudoxos avatar Dec 02 '20 11:12 eudoxos