2016-06-16 10:14:45 +00:00
|
|
|
define [
|
|
|
|
"libs/latex-log-parser"
|
2016-06-16 14:29:00 +00:00
|
|
|
"ide/human-readable-logs/HumanReadableLogsRules"
|
|
|
|
], (LogParser, ruleset) ->
|
2016-06-16 10:14:45 +00:00
|
|
|
parse : (rawLog, options) ->
|
2016-07-27 15:51:13 +00:00
|
|
|
if typeof rawLog is 'string'
|
|
|
|
parsedLogEntries = LogParser.parse(rawLog, options)
|
|
|
|
else
|
|
|
|
parsedLogEntries = rawLog
|
2016-06-16 14:29:00 +00:00
|
|
|
|
2016-06-17 10:42:32 +00:00
|
|
|
_getRule = (logMessage) ->
|
|
|
|
return rule for rule in ruleset when rule.regexToMatch.test logMessage
|
2016-06-16 14:53:39 +00:00
|
|
|
|
|
|
|
for entry in parsedLogEntries.all
|
2016-06-21 11:07:47 +00:00
|
|
|
ruleDetails = _getRule entry.message
|
2016-06-16 14:29:00 +00:00
|
|
|
|
2016-06-21 11:07:47 +00:00
|
|
|
if (ruleDetails?)
|
2016-07-27 15:52:36 +00:00
|
|
|
if ruleDetails.ruleId?
|
|
|
|
entry.ruleId = ruleDetails.ruleId
|
|
|
|
else if ruleDetails.regexToMatch?
|
|
|
|
entry.ruleId = 'hint_' + ruleDetails.regexToMatch.toString().replace(/\s/g, '_').slice(1, -1)
|
|
|
|
if ruleDetails.newMessage?
|
|
|
|
entry.message = entry.message.replace ruleDetails.regexToMatch, ruleDetails.newMessage
|
2016-06-30 10:30:43 +00:00
|
|
|
|
2016-06-21 11:07:47 +00:00
|
|
|
entry.humanReadableHint = ruleDetails.humanReadableHint if ruleDetails.humanReadableHint?
|
|
|
|
entry.extraInfoURL = ruleDetails.extraInfoURL if ruleDetails.extraInfoURL?
|
|
|
|
|
2016-06-16 10:14:45 +00:00
|
|
|
return parsedLogEntries
|