Open jonashaag opened 1 year ago
My current solution
def log_filter(record):
msg = record.getMessage()
return not msg.startswith(
(
"DELETE FROM #pytsql_prints",
"SELECT * FROM #pytsql_prints",
"CREATE TABLE #pytsql_prints",
"DROP TABLE IF EXISTS #pytsql_prints",
# non-pytsql noise
"COMMIT using DBAPI",
"[raw sql] ()",
"SELECT CAST('test max support",
"SELECT CAST(SERVERPROPERTY('ProductVersion')",
"SELECT schema_name()",
"SELECT [INFORMATION_SCHEMA].[TABLES].[TABLE_NAME]",
"[generated in ",
"[cached since",
)
)
for handler in logging.getLogger().handlers:
handler.addFilter(log_filter)
This is the point of using a log filter. My only suggestion would be to split it in two one for pytsql and the other for the extra noise you want to filter out.
I wonder if there is something that we can implement in pytsql to optionally disable printing of the
#pytsql_prints
related lines to the SQLAlchemy logger.