New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom message in logging queries #285
Comments
@josephmancuso Can we change the current default message that are being used inside code? |
which one? |
if you mean the one that is printing out in the connection classes, that really shouldn't be there. I just put that there for now so I can easily debug things as we test it |
Yep, that one! Then the message putted in formatter should be cascade until base code... |
yeah the one printing will be removed soon. You can look into adding some more options to the formatter tho. I think currently it only does query and query time |
@josephmancuso What do you think of this, change the "format" of define logging to encapsulate all of initial configs: from: logger = logging.getLogger('masoniteorm.connection.queries')
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter(
'It executed the query %(query)s'
)
stream_handler = logging.StreamHandler()
file_handler = logging.FileHandler("queries.log")
logger.addHandler(stream_handler)
logger.addHandler(file_handler) to: ...
formatter = "It executed the query %(query)s" # Message with more placeholders
handlers = [logging.StreamHandler(), logging.FileHandler("queries.log")]
logger = Logger.configure(formatter, handlers=handlers) |
yeah that's fine |
@josephmancuso this logger to logging queries will be used to all types of infos or just sql queries? Ask this because if to just sql query just need the "info" level of log, if not, then I need create other levels. I'll open the PR to analysis. |
Define a custom messsage to logging queries.
The text was updated successfully, but these errors were encountered: