UNPKG

glutenfree

Version:

A profiler/loganalyzer for nginx/Cetrea Aw.

53 lines (47 loc) 1.72 kB
// Generated by CoffeeScript 1.6.3 var AwLogLineParser, __slice = [].slice; AwLogLineParser = (function() { function AwLogLineParser() {} AwLogLineParser.prototype.parse = function(line) { var action, args, clazz, component, componentVersion, endpoint, fun, ip, level, m, method, path, r, re, thread, time, url, __; re = /(\d{2}:\d{2}:\d{2}\.\d{3})\s+(\[.+\])\s+(\S+)\s+(\S+)\s+-\s+.*:\s+([\d\.]+)\s+-\s+(\S+)\s+-(.+)/i; m = line.match(re); if (m != null) { __ = m[0], time = m[1], thread = m[2], level = m[3], clazz = m[4], ip = m[5], method = m[6], path = m[7]; r = path.split("/"); if ((r != null ? r.length : void 0) > 2) { if (r[2].indexOf(".") > 0) { __ = r[0], action = r[1], component = r[2], componentVersion = r[3], endpoint = r[4], fun = r[5], args = 7 <= r.length ? __slice.call(r, 6) : []; } else { __ = r[0], action = r[1], endpoint = r[2], fun = r[3], args = 5 <= r.length ? __slice.call(r, 4) : []; } url = [action, component, componentVersion, endpoint, fun].filter(function(c) { return c != null; }).concat(args).join("/"); return { variables: { ip: ip, time: time, thread: thread }, method: method, component: component, componentVersion: componentVersion, action: action, endpoint: endpoint, fun: fun, args: args.join("/"), url: url, id: method + " " + url }; } else { return false; } } else { return false; } }; return AwLogLineParser; })(); exports.parser = new AwLogLineParser();