Coder Social home page Coder Social logo

node-alpine's People

Contributors

blarsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

node-alpine's Issues

Support ISO-8601 timestamp without brackets

Parser requires time to be in brackets. I'm assuming this is a convenient assumption. It makes it easy to find all the data, even if they contain spaces. However, AWS ELB logs use ISO-8601 format without brackets.

Example: 2019-06-29T12:40:00.547997Z

This is a very common, portable, and parsable date format. It should be supported with a new format field.

Allow custom error handler on fail of parseLine

Great package!

I am using this and found that if one log line fails it kills the script.

I thought it would be better if the parseLine method had a catch in case for any reason one log line was poorly formatted and it doesn't affect the whole parsing operation. I think the best case would be to be able to pass a custom error handler when there is a message.

Just a small thought as an enhancement. Thank you so much!

    try {
        this.formatfields.forEach(function(field) {
            buf.skipSpaces();
            var val;
            if (field.isQuoted) {
                if (!(buf.lookingAt() === '"'))
                    throw new Error("Field defined as quoted was not quoted");
                buf.skip();
                val = buf.getUpto('"');
                buf.skip();
            } else if (field.isDate) {
                if (!(buf.lookingAt() === '['))
                    throw new Error("Time field is not enclosed in brackets");
                buf.skip();
                val = buf.getUpto(']');
                buf.skip();
            } else {
                val = buf.getUpto(' ');
            }
            result[field.name] = val;
        })
    } catch (e) {
        result.error = e.message;
    }

Multiple fields within quotes not handled

Alpine successfully handles a log format with a single field inside quotes, e.g.

var alpine = new Alpine("\"%h\"");

However it doesn't like it if the log format has multiple fields inside the same set of quotes, e.g.

var alpine = new Alpine("\"%h %h\"");

I believe having multiple fields inside the same set of quotes is a valid scenario.

The stacktrace:

S:\dev\scratch\node_modules\alpine\alpine.js:110
            throw new Error("Field does not start with %: "+field);
            ^

Error: Field does not start with %: "%h
    at parseLogFormat (S:\dev\scratch\node_modules\alpine\alpine.js:110:19)
    at setLogFormat (S:\dev\scratch\node_modules\alpine\alpine.js:65:25)
    at new Alpine (S:\dev\scratch\node_modules\alpine\alpine.js:25:14)
    at Object.<anonymous> (S:\dev\scratch\selflog2sp.js:4:14)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.