How do i pass a flask app.logger to another python file? /u/migustapapaya Python Education

app.py:

from flask import Flask, request, url_for import os from auth.logger import hi from logging.config import dictConfig dictConfig({ 'version': 1, 'formatters': {'default': { 'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s', }}, 'handlers': {'wsgi': { 'class': 'logging.StreamHandler', 'stream': 'ext://flask.logging.wsgi_errors_stream', 'formatter': 'default' }}, 'root': { 'level': 'INFO', 'handlers': ['wsgi'] } }) app = Flask(__name__) .route("/test") def test(): hi() return "Test" 

auth/logger.py

import logging log = logging.getLogger('app.hi') def hi(): print(log.parent) log.warning('warning test') 

The parent printed out is <Logger app (INFO)>. But why am I not able to log the warning out?

submitted by /u/migustapapaya
[link] [comments]

​r/learnpython app.py: from flask import Flask, request, url_for import os from auth.logger import hi from logging.config import dictConfig dictConfig({ ‘version’: 1, ‘formatters’: {‘default’: { ‘format’: ‘[%(asctime)s] %(levelname)s in %(module)s: %(message)s’, }}, ‘handlers’: {‘wsgi’: { ‘class’: ‘logging.StreamHandler’, ‘stream’: ‘ext://flask.logging.wsgi_errors_stream’, ‘formatter’: ‘default’ }}, ‘root’: { ‘level’: ‘INFO’, ‘handlers’: [‘wsgi’] } }) app = Flask(__name__) .route(“/test”) def test(): hi() return “Test” auth/logger.py import logging log = logging.getLogger(‘app.hi’) def hi(): print(log.parent) log.warning(‘warning test’) The parent printed out is <Logger app (INFO)>. But why am I not able to log the warning out? submitted by /u/migustapapaya [link] [comments] 

app.py:

from flask import Flask, request, url_for import os from auth.logger import hi from logging.config import dictConfig dictConfig({ 'version': 1, 'formatters': {'default': { 'format': '[%(asctime)s] %(levelname)s in %(module)s: %(message)s', }}, 'handlers': {'wsgi': { 'class': 'logging.StreamHandler', 'stream': 'ext://flask.logging.wsgi_errors_stream', 'formatter': 'default' }}, 'root': { 'level': 'INFO', 'handlers': ['wsgi'] } }) app = Flask(__name__) .route("/test") def test(): hi() return "Test" 

auth/logger.py

import logging log = logging.getLogger('app.hi') def hi(): print(log.parent) log.warning('warning test') 

The parent printed out is <Logger app (INFO)>. But why am I not able to log the warning out?

submitted by /u/migustapapaya
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *