0

I have written a logger, but now whenever I run it all I see are SQL statements from my execute statements. Is there a way to remove these statements from my log

[Wed, 17 Sep 2014 11:30:17] - execute - (0.000) SELECT `main_provider`.`name`, `main_provider`.`test_mode`, `main_provider`.`is_active`, `main_provider`.`allowed_domains`, `main_provider`.`xlsx_template_url`, `main_provider`.`itunes_film_name`, `main_provider`.`itunes_film_username`, `main_provider`.`itunes_film_password`, `main_provider`.`itunes_tv_name`, `main_provider`.`itunes_tv_username`, `main_provider`.`itunes_tv_password`, `main_provider`.`premiere_can_view_provider`, `main_provider`.`rate_per`, `main_provider`.`rate_cap`, `main_provider`.`rate_offset` FROM `main_provider` WHERE `main_provider`.`name` = 'studiocanal' ; args=('studiocanal',)
[Wed, 17 Sep 2014 11:30:17] - execute - (0.000) SELECT `main_provider`.`name`, `main_provider`.`test_mode`, `main_provider`.`is_active`, `main_provider`.`allowed_domains`, `main_provider`.`xlsx_template_url`, `main_provider`.`itunes_film_name`, `main_provider`.`itunes_film_username`, `main_provider`.`itunes_film_password`, `main_provider`.`itunes_tv_name`, `main_provider`.`itunes_tv_username`, `main_provider`.`itunes_tv_password`, `main_provider`.`premiere_can_view_provider`, `main_provider`.`rate_per`, `main_provider`.`rate_cap`, `main_provider`.`rate_offset` FROM `main_provider` WHERE `main_provider`.`name` = 'summit' ; args=('summit',)
[Wed, 17 Sep 2014 11:30:17] - send_confirmation_email - >>>>> Sending FAILURE email confirmation.

In the above, I would only want the statement in the function send_confirmation_email

David542
  • 104,438
  • 178
  • 489
  • 842
  • 1
    In what context? Are you using SQLAlchemy by any chance? Any framework? – Lukas Graf Sep 17 '14 at 18:34
  • It depends. We don't know what your code logger does, what logic it follows, etc... the best any of us could do is guess. My guess would be that you should check out regular expressions. They might be able to help you decide which code to log and which code not to log. But really, that is just a guess. Without more info, none of us can help. – Evan Volgas Sep 17 '14 at 18:36
  • 1
    if you just want to edit this log , you dont need python, you can do this using shell commands `grep -v 'SELECT' name_of_log_file > new_log` – g4ur4v Sep 17 '14 at 18:36
  • There is some code somewhere that is accessing your logger and sending log statements to it. Either find the code and remove it, add a config option to disable it, or set some kind of logging level filter. If this is coming from someone else's code, you'll either have to find a way provided by the library to disable it or monkey patch it (or modify the source, of course). – jpmc26 Sep 17 '14 at 18:37
  • possible duplicate of [How to stop sql logging in debug mode?](http://stackoverflow.com/questions/6867598/how-to-stop-sql-logging-in-debug-mode) *(without further clarification from the OP I'm assuming he's using Django)* – Lukas Graf Sep 17 '14 at 18:42

0 Answers0