Coder Social home page Coder Social logo

logger's Introduction

Logger

A centralized logging processor for js

But why?

Let's say you are testing on many different devices and the only way to get some logs from it is to plug it into your computer and run the web app. Wash and repeat for every device that you are needed to test with. A good example is when you start using location api, what are your devices actually doing and are they providing the same kind of information? This is the type of situation that could be made better by being able to throw Logger.js on your site, specify the listener and processor files, and run the site on any device. Your logs will be in the location you specified on your Processor.php file.

It's safe to say this is geared towards the testing / development part of the software lifecycle.

A little setup needed..

We need to do a little set up first, add the processor.php file and listener.php files onto your web server. Then, the Logger.js file will need to go on any page you wish to use these features with but it doesn't have to be the same domain as your server. Then pass the processorUrl and the listenerUrl to the Logger.settings(); (see example.html) so logger knows where to send the data.

In the processor.php file you will need identify the file location and turn the $loggingTurnedOn flag on when you are ready to accept logs.

If you are logging from a domain that is different than the domain that the processor.php file resides, you will need to set up your listener.php by popluating the allowedDomains array with the complete domain (with ports if they are different than the default).

How does it work?

The idea is to override the console.log method to post the logs back to the processor.php. Which, in turn, will post to the specified log file. To help with perfomance, we send the buffered array of logs in groups at different points of the page cycle: the first group goes on window.load and the proceding logs will be set 1 second after a log was made and that pattern repeats each time a log is made.

Note: you don't have to do anything new syntatically, this solution just adds more functionality to the console.log method you are already using.

If you have any ideas for making this better please let me know or fork it and show me. Thanks guys!

logger's People

Contributors

sean-roberts avatar

Watchers

 avatar  avatar  avatar

logger's Issues

sessions are not grouped properly

Currently, since the logs are sent every second, the session context when the log was made is not put into consideration upon sending of the data - only the context in which the logger is currently in is taken into consideration when the data is sent.

Expected: data will write to the session in which is is created under

Possible Fix: grouping of the logs by session to stop this problem

Workaround: no real work around available. However, the more common use case for this is a user setting the session for his testing. This is done once at the top - usually. So the %80 is covered

postMessage target origin

The listenerOrigin was passed to the constructor but never enforced / passed to the postMessage method.

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.