You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now i want to get_logger in controller. Here is how i've used it in auth_controller
from ..service.logging_service import get_logger
_logger = get_logger(__name__)
@api.route('/login')
class Login(Resource):
@api.doc('user_login')
@api.expect(_login, validate=True)
def post(self):
_logger.error("Logging Test")
For brevity I've removed unwanted code from auth_controller.
Now the problem is that when i try to run application it tries to run auth_controller first, which crashes due the fact that we haven't initiate the config object on app. It is initiated when create_app is called from manage.py.
Can you kindly suggest what can be done to resolve this issue?
Regards
The text was updated successfully, but these errors were encountered:
Hi @fullonic,
I've used the python configuration file for now. I haven't been able to see the way to use config file entries in any file that is going to be executed before initiating the configurations. If you have any suggestions, then kindly let me know.
Hi @zrehman-ssi , from what do you explains and reading your code, I believe that your are running into "circular imports issues" because your are importing the app. When using the app factory, or the def create_app(): and you need to import your app in some module, flask provides from flask import current_app. So, doing that, get_logger() would be:
from flask import current_app
def get_logger(name):
# use current_app instead of app
log_format = current_app.config['LOGGING_MESSAGE_FORMAT']
(...)
Hi,
First of all thank you very much for such a great boilerplate. I'm facing an issue that i would like to know your thoughts about.
I've created a logging service in Service package which is in main package. Here is the content of loggingservice.
Now i want to get_logger in controller. Here is how i've used it in auth_controller
For brevity I've removed unwanted code from auth_controller.
Now the problem is that when i try to run application it tries to run auth_controller first, which crashes due the fact that we haven't initiate the config object on app. It is initiated when create_app is called from manage.py.
Can you kindly suggest what can be done to resolve this issue?
Regards
The text was updated successfully, but these errors were encountered: