UNPKG

glutenfree

Version:

A profiler/loganalyzer for nginx/Cetrea Aw.

53 lines (47 loc) 1.64 kB
// Generated by CoffeeScript 1.6.3 var AwNginxLineParser, __slice = [].slice; AwNginxLineParser = (function() { function AwNginxLineParser() {} AwNginxLineParser.prototype.parse = function(line) { var action, args, endpoint, fun, instance, ip, m, method, path, protocol, r, re, referer, request, time, url, useragent, __, _ref; re = /((\d+\.*)+).*\[(.*)\]\s\"(.*)\"\s(\d+)\s(\d+)\s\"(.*)\"\s\"(.*)\"/i; m = line.match(re); if (m) { __ = m[0], ip = m[1], __ = m[2], time = m[3], request = m[4], __ = m[5], referer = m[6], __ = m[7], useragent = m[8], __ = m[9]; _ref = request.match(/(.*)\s(.*)\s(.*)/), __ = _ref[0], method = _ref[1], path = _ref[2], protocol = _ref[3], __ = _ref[4]; r = path.split("/"); if (r) { __ = r[0], instance = r[1], action = r[2], endpoint = r[3], fun = r[4], args = 6 <= r.length ? __slice.call(r, 5) : []; } else { return false; } url = [action, component, componentVersion, endpoint, fun].filter(function(c) { return c != null; }).concat(args).join("/"); return { variables: { ip: ip, time: time, referer: referer, useragent: useragent }, method: method, protocol: protocol, instance: instance, component: null, componentVersion: null, action: action, endpoint: endpoint, fun: fun, args: args, url: url, id: method + " " + url }; } else { return false; } }; return AwNginxLineParser; })(); exports.parser = new AwNginxLineParser();