Giter Site home page Giter Site logo

jslogger's Introduction

jslogger

Logging javascript logs to server

Usage

You can install the jslogger using

npm install @nudjur/js-logger

Once installed you can import it as below in your js file

import jsLogger from "@nudjur/js-logger";

export const log = new jsLogger({
  url: <URL>,
  mode: <MODE>
  time_ms: <TIME_MS>
});

Configuration

  1. url: The backend url where jslogger should send logs
  2. mode: Backend url run on different modes such as DEBUG, INFO where if it is DEBUG mode will write debug logs such as click event
  3. time_ms: jslogger store all logs in localstorage and keeps checking if logs present and push it so we can configure the frequency by this args default: 5sec
  4. maxLogs: jslogger will have a threshold that once a count of logs comes to localstorage it will start pushing we can adjust using this default : 1000

Contributing Guideline

To contribute to the repo you clone the repo and create a new branch and start making changes in src/index.js.

  1. Once you are done making changes do update the package.json
version: "0.0.2" => "0.0.3"
  1. After updating version we will need to build also we can do that by using
npm run build
  1. After this we can push all changes to branch and assign the maintainer for review

  2. Once pr is merged maintainer will have to release to npm he can do so by

npm publish --access public

NOTE:- We will need to be logged in node repo for nudjur

Server side

  • The logs will be logged via axios call in post method with a variable logs. The server side script should be able to take the request with argument logs. Below is a example of form data for ajax call.
{
log:[
        {
        UUID: '181393b0-8702-11e7-9ca6-a7e5a0572c550.8393907533887879', //sortable unique number
        level : info/log/debug/error/user message/warn/exception/ajax,
        message: 'message',
        user: 'user if specified',
        url: 'url where log happened',
        host_url: 'host url(domain)',
        misc: 'any extra data user specifies that is used while logging'
        },
        {}, {}, ....
    ]
}

jslogger's People

Contributors

dependabot[bot] avatar jaswanth098 avatar purushothaman-source avatar umangthapliyal avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jslogger's Issues

Update readme

We have made certain changes which need to be updated in the doc

  • Npm pakcage installation
  • Usage
  • Remove deprecated axios
  • dependency updated

remove window dependency

When we are using it in the normal node we dont have access to window and document object so it is throwing error for that we need to make it so that in the constructor we check for the window object if window is not present we store it in variable

Bug in jslogger

Bugs in js logger:

  • Max log counter is not reinitialized whenever the flushing logs function is invoked based on time interval.
  • When ever sending logs to the server fails to send next time_interval or max_logs functions doesn't invoke flushing log function.

add condition for empty array

when we are running the service as node we are getting it as array and thats why condition is not met we need to add condition to check and close once the length is 0

handle empty localstorage

Currently we will initialize the var as empty string and we are checking the length of itinstead we should check the value. There are two condition currently where when we are running in browser we are taking it as string because localstorage and when in node we are taking as array because there we have variable we need to make sure we are using one data type

create release for the repo

Currently we are alwyas refreing to latest version for the repo but we need version managment and proper release for this for open source we have free node and free deployment will add that here

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.