Skip to content
Snippets Groups Projects
Commit 3c3e404e authored by anonymous's avatar anonymous
Browse files

first try on uls

parent b1067161
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,56 @@ log = logging.getLogger(__name__)
_ = toolkit._
from multiline_formatter.formatter import MultilineMessagesFormatter
class OdshLogger(MultilineMessagesFormatter):
multiline_marker = '...'
multiline_fmt = multiline_marker + ' : %(message)s'
def format(self, record):
"""
This is mostly the same as logging.Formatter.format except for the splitlines() thing.
This is done so (copied the code) to not make logging a bottleneck. It's not lots of code
after all, and it's pretty straightforward.
"""
endl_marker = '\n... : ";'
record.message = record.getMessage()
if self.usesTime():
record.asctime = self.formatTime(record, self.datefmt)
if '\n' in record.message:
splitted = record.message.splitlines()
output = self._fmt % dict(record.__dict__, message=splitted.pop(0))
output += ' ' + self.multiline_marker % record.__dict__ + '\n'
output += '\n'.join(
self.multiline_fmt % dict(record.__dict__, message=line)
for line in splitted
)
output = output.replace('"','\\\\"')
output += endl_marker
else:
output = self._fmt % record.__dict__
if record.exc_info:
# Cache the traceback text to avoid converting it multiple times
# (it's constant anyway)
if not record.exc_text:
record.exc_text = self.formatException(record.exc_info)
if record.exc_text:
output += ' ' + self.multiline_marker % record.__dict__ + '\n'
try:
output += '\n'.join(
self.multiline_fmt % dict(record.__dict__, message=line)
for index, line in enumerate(record.exc_text.splitlines())
)
output = output.replace('"','\\\\"')
output += endl_marker
except UnicodeError:
output += '\n'.join(
self.multiline_fmt % dict(record.__dict__, message=line)
for index, line
in enumerate(record.exc_text.decode(sys.getfilesystemencoding(), 'replace').splitlines())
)
return output
def odsh_get_facet_items_dict(name, limit=None):
'''
......@@ -304,6 +354,10 @@ class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation, DefaultDatasetForm
# use several daterange queries agains temporal_start and temporal_end field
# TODO: use field of type date_range in solr index instead
def before_search(self, search_params):
try:
raise BaseException('boom')
except:
log.exception("got exception")
extras = search_params.get('extras')
if not extras:
......
uls.conf 0 → 100644
inputfile = test.log
outputfile = ./out.uls
# %F = YYYY-MM-DD
# %T = hh:mm:ss
# %W = der ganze Rest
#inputformat = {"asctime": "%F %T,%c%c%c", "levelname": "ERROR", "name": "%q", "message": "%W
iformat0 = %F %T,%c%c%c ERROR [%q] got exception ...%W
#nreadformat0 =... (7568:worker 2) : %W
nreadformat0 =... : %W
# Alle Zeilen, die ERR enthalten
reg0 = got exception ...
nreadreg0 =^... :
#consolidate0 = 0/1s: 2
# Gebe die ganze Zeile auf stdout aus
#eaction = echo %F %T %q
#action0 = echo %F %T [%q,%p] %W
#nreadaction0 = echo %W
##write0 = V;%F %T;source;"section";"teststep";"detail";"Text"; [%q,%p] %W
write0 = V;%F %T;ckan274;"ULS";"Test";"detail";"Text";"
nreadwrite0 = %W
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment