Skip to content

fix tracers and logging Working outside of application context#76

Merged
avara1986 merged 4 commits intomasterfrom
fix/loggers_out_of_context
Dec 15, 2019
Merged

fix tracers and logging Working outside of application context#76
avara1986 merged 4 commits intomasterfrom
fix/loggers_out_of_context

Conversation

@avara1986
Copy link
Member

Fix error log when use logger working outside of application context

import logging
from pyms.constants import LOGGER_NAME
from pyms.flask.app import Microservice

logger = logging.getLogger(LOGGER_NAME)

app = Microservice(service="my-minimal-microservice", path=__file__).create_app()
logger.debug("holi")

return:

ERROR:pyms-tracer:Tracer error Working outside of application context.

This typically means that you attempted to use functionality that needed
to interface with the current application object in some way. To solve
this, set up an application context with app.app_context().  See the
documentation for more information.
{"timestamp": "2019-12-13T07:54:25.730062Z", "level": null, "name": "pyms", "module": "test", "funcName": "<module>", "lineno": 10, "message": "holi", "severity": "DEBUG", "service": "python microservice"}
import logging
from pyms.constants import LOGGER_NAME
from pyms.flask.app import Microservice

logger = logging.getLogger(LOGGER_NAME)

app = Microservice(service="my-minimal-microservice", path=__file__).create_app()
with app.app_context():
    logger.debug("holi")

return

ERROR:pyms-tracer:Tracer error Working outside of request context.

This typically means that you attempted to use functionality that needed
an active HTTP request.  Consult the documentation on testing for
information about how to avoid this problem.
{"timestamp": "2019-12-13T07:55:08.355171Z", "level": null, "name": "pyms", "module": "test", "funcName": "<module>", "lineno": 11, "message": "holi", "severity": "DEBUG", "service": "python microservice"}

@avara1986 avara1986 requested a review from alexppg December 13, 2019 16:06
@coveralls
Copy link

coveralls commented Dec 13, 2019

Coverage Status

Coverage decreased (-0.0007%) to 99.681% when pulling 58da91c on fix/loggers_out_of_context into b48232f on master.

@avara1986 avara1986 merged commit e8db8d8 into master Dec 15, 2019
@alexppg
Copy link
Member

alexppg commented Dec 15, 2019

LGTM aunque ya esté, que lo había leído pero no probado. gracias!

@avara1986 avara1986 deleted the fix/loggers_out_of_context branch December 15, 2019 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants