overleaf/services/web/public/coffee/ide/human-readable-logs/HumanReadableLogs.coffee

18 lines
660 B
CoffeeScript
Raw Normal View History

define [
"libs/latex-log-parser"
2016-06-16 10:29:00 -04:00
"ide/human-readable-logs/HumanReadableLogsRules"
], (LogParser, ruleset) ->
parse : (rawLog, options) ->
parsedLogEntries = LogParser.parse(rawLog, options)
2016-06-16 10:29:00 -04:00
_getRule = (logMessage) ->
return rule for rule in ruleset when rule.regexToMatch.test logMessage
for entry in parsedLogEntries.all
{ regexToMatch, humanReadableHint, extraInfoURL } = _getRule entry.message
entry.ruleId = 'hint_' + regexToMatch.toString().replace(/[^a-zA-Z0-9]/g, '_').toLowerCase()
entry.humanReadableHint = humanReadableHint if humanReadableHint?
entry.extraInfoURL = extraInfoURL if extraInfoURL?
2016-06-16 10:29:00 -04:00
return parsedLogEntries