From e4a14199d57455083e71f7b68b78fc231d32fc77 Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 04:28:12 -0400 Subject: Usando logging correcto de Python --- cgi/weabot.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'cgi/weabot.py') diff --git a/cgi/weabot.py b/cgi/weabot.py index 3c5d0f5..ff93118 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -8,6 +8,7 @@ import time import datetime import random import cgi +import logging import _mysql from Cookie import SimpleCookie @@ -33,6 +34,9 @@ _LOG = False class weabot(object): def __init__(self, environ, start_response): global _DEBUG + + logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG) + self.environ = environ if self.environ["PATH_INFO"].startswith("/weabot.py/"): self.environ["PATH_INFO"] = self.environ["PATH_INFO"][11:] @@ -48,7 +52,6 @@ class weabot(object): 'weabot', './locale', languages=[Settings.LANG]) lang.install() - logTime("**Start**") if _DEBUG: import cProfile @@ -70,12 +73,6 @@ class weabot(object): # close database and finish CloseDb() - logTime("**End**") - - if _LOG: - logfile = open(Settings.ROOT_DIR + "weabot.txt", "w") - logfile.write(logTimes()) - logfile.close() def __iter__(self): self.handleResponse() @@ -812,7 +809,7 @@ class weabot(object): post["message"]), _mysql.escape_string(board["id"]), _mysql.escape_string(str(postid)))) # do operations if replying to a thread (bump, autoclose, update cache) - logTime("Updating thread") + logging.debug("Updating thread") thread_length = None if post["parentid"]: # get length of the thread @@ -1086,7 +1083,7 @@ if __name__ == "__main__": # Psyco is not required, however it will be used if available try: import psyco - logTime("Psyco se ha instalado") + logging.debug("Psyco se ha instalado") psyco.bind(tenjin.helpers.to_str) psyco.bind(weabot.run, 2) psyco.bind(getFormData) -- cgit v1.2.1-18-gbd029 From e8049e9b5a50ad432e87fb28bd93b929e74b8d8a Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 04:29:23 -0400 Subject: Arreglado manejo de países --- cgi/weabot.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cgi/weabot.py') diff --git a/cgi/weabot.py b/cgi/weabot.py index ff93118..5f659e0 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -729,8 +729,6 @@ class weabot(object): if board["slip"] == '2': if hide_end: host = '★' - elif addressIsTor(ip): - host = 'onion' else: host = getHost(ip) if host: @@ -764,7 +762,7 @@ class weabot(object): if hide_end or addressIsTor(ip): country = '??' else: - country = getCountry(ip) + country = getCountry(ip) or '??' post["name"] += " [%s]" % country # set expiration date if necessary -- cgit v1.2.1-18-gbd029 From 109f8e55385fa37946fa7ad0ac90cc87d738a72c Mon Sep 17 00:00:00 2001 From: bai Date: Tue, 28 Jul 2020 05:33:38 -0400 Subject: Cambiado nivel de logging a WARN --- cgi/weabot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cgi/weabot.py') diff --git a/cgi/weabot.py b/cgi/weabot.py index 5f659e0..b8b9f96 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -35,7 +35,7 @@ class weabot(object): def __init__(self, environ, start_response): global _DEBUG - logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.DEBUG) + logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.WARN) self.environ = environ if self.environ["PATH_INFO"].startswith("/weabot.py/"): -- cgit v1.2.1-18-gbd029 From 256445343323a7cb4e9015f680af8c7a387d6f1b Mon Sep 17 00:00:00 2001 From: bai Date: Thu, 30 Jul 2020 05:52:28 -0400 Subject: Agregado logeo de excepciones --- cgi/weabot.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cgi/weabot.py') diff --git a/cgi/weabot.py b/cgi/weabot.py index b8b9f96..d809cf0 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -64,6 +64,8 @@ class weabot(object): except UserError, message: self.error(message) except Exception, inst: + logging.exception(inst) + import sys import traceback exc_type, exc_value, exc_traceback = sys.exc_info() -- cgit v1.2.1-18-gbd029 From 89630525f6d84cd58ffa6df79751bf4ff3946fcb Mon Sep 17 00:00:00 2001 From: neptune Date: Thu, 30 Jul 2020 06:01:45 -0400 Subject: Logeando INFO por defecto --- cgi/weabot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cgi/weabot.py') diff --git a/cgi/weabot.py b/cgi/weabot.py index d809cf0..f92e777 100755 --- a/cgi/weabot.py +++ b/cgi/weabot.py @@ -35,7 +35,7 @@ class weabot(object): def __init__(self, environ, start_response): global _DEBUG - logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.WARN) + logging.basicConfig(filename='weabot.log', format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO) self.environ = environ if self.environ["PATH_INFO"].startswith("/weabot.py/"): -- cgit v1.2.1-18-gbd029