Try and encode logging messages. fix #403
This commit is contained in:
@@ -80,7 +80,7 @@ class Plugin(object):
|
||||
f.close()
|
||||
os.chmod(path, Env.getPermission('file'))
|
||||
except Exception, e:
|
||||
log.error('Unable writing to file "%s": %s' % (path, e))
|
||||
log.error('Unable writing to file "%s": %s', (path, e))
|
||||
|
||||
def makeDir(self, path):
|
||||
try:
|
||||
@@ -88,7 +88,7 @@ class Plugin(object):
|
||||
os.makedirs(path, Env.getPermission('folder'))
|
||||
return True
|
||||
except Exception, e:
|
||||
log.error('Unable to create folder "%s": %s' % (path, e))
|
||||
log.error('Unable to create folder "%s": %s', (path, e))
|
||||
|
||||
return False
|
||||
|
||||
@@ -106,7 +106,7 @@ class Plugin(object):
|
||||
# Don't try for failed requests
|
||||
if self.http_failed_disabled.get(host, 0) > 0:
|
||||
if self.http_failed_disabled[host] > (time.time() - 900):
|
||||
log.info('Disabled calls to %s for 15 minutes because so many failed requests.' % host)
|
||||
log.info('Disabled calls to %s for 15 minutes because so many failed requests.', host)
|
||||
raise Exception
|
||||
else:
|
||||
del self.http_failed_request[host]
|
||||
@@ -116,7 +116,7 @@ class Plugin(object):
|
||||
try:
|
||||
|
||||
if multipart:
|
||||
log.info('Opening multipart url: %s, params: %s' % (url, [x for x in params.iterkeys()]))
|
||||
log.info('Opening multipart url: %s, params: %s', (url, [x for x in params.iterkeys()]))
|
||||
request = urllib2.Request(url, params, headers)
|
||||
|
||||
cookies = cookielib.CookieJar()
|
||||
@@ -124,7 +124,7 @@ class Plugin(object):
|
||||
|
||||
data = opener.open(request, timeout = timeout).read()
|
||||
else:
|
||||
log.info('Opening url: %s, params: %s' % (url, [x for x in params.iterkeys()]))
|
||||
log.info('Opening url: %s, params: %s', (url, [x for x in params.iterkeys()]))
|
||||
data = tryUrlencode(params) if len(params) > 0 else None
|
||||
request = urllib2.Request(url, data, headers)
|
||||
|
||||
@@ -133,7 +133,7 @@ class Plugin(object):
|
||||
self.http_failed_request[host] = 0
|
||||
except IOError:
|
||||
if show_error:
|
||||
log.error('Failed opening url in %s: %s %s' % (self.getName(), url, traceback.format_exc(1)))
|
||||
log.error('Failed opening url in %s: %s %s', (self.getName(), url, traceback.format_exc(1)))
|
||||
|
||||
# Save failed requests by hosts
|
||||
try:
|
||||
@@ -147,7 +147,7 @@ class Plugin(object):
|
||||
self.http_failed_disabled[host] = time.time()
|
||||
|
||||
except:
|
||||
log.debug('Failed logging failed requests for %s: %s' % (url, traceback.format_exc()))
|
||||
log.debug('Failed logging failed requests for %s: %s', (url, traceback.format_exc()))
|
||||
|
||||
raise
|
||||
|
||||
@@ -163,7 +163,7 @@ class Plugin(object):
|
||||
wait = math.ceil(last_use - now + self.http_time_between_calls)
|
||||
|
||||
if wait > 0:
|
||||
log.debug('Waiting for %s, %d seconds' % (self.getName(), wait))
|
||||
log.debug('Waiting for %s, %d seconds', (self.getName(), wait))
|
||||
time.sleep(last_use - now + self.http_time_between_calls)
|
||||
|
||||
def beforeCall(self, handler):
|
||||
@@ -202,7 +202,7 @@ class Plugin(object):
|
||||
cache_key = simplifyString(cache_key)
|
||||
cache = Env.get('cache').get(cache_key)
|
||||
if cache:
|
||||
if not Env.get('dev'): log.debug('Getting cache %s' % cache_key)
|
||||
if not Env.get('dev'): log.debug('Getting cache %s', cache_key)
|
||||
return cache
|
||||
|
||||
if url:
|
||||
@@ -220,7 +220,7 @@ class Plugin(object):
|
||||
pass
|
||||
|
||||
def setCache(self, cache_key, value, timeout = 300):
|
||||
log.debug('Setting cache %s' % cache_key)
|
||||
log.debug('Setting cache %s', cache_key)
|
||||
Env.get('cache').set(cache_key, value, timeout)
|
||||
return value
|
||||
|
||||
|
||||
Reference in New Issue
Block a user