Git Product home page Git Product logo

jslogger's Introduction

JsLogger

A simple JavaScript logger that utilizes storage and can send the logs to a server to integrate with your application logs

###Basic Usage

var myJsLoggerOptions = { 
  LoggingUrl: '/App/Utility/JavaScriptLog', 
  MaxLogsBeforeDump: 2, 
  DumpLogsOverride: dumpLogOverride 
};
JSLogger.Init(myJsLoggerOptions);
JSLogger.MakeLog("INFO", "App.js", "Initialization", JSLogger.JSLog.GetData("App Initialized."), false);

###Logger Options

Option Type Required Description
LoggingUrl url true Web server url to pass logs to when the max bucket size is reached or if the browser is shut down
MaxLogsBeforeDump number true Total logs that the library will hold onto until it attemps to send them to the parameter set in LoggingUrl
DumpLogsOverride function false User defined function to override the default log behavior. For example, if you want to write to the console or do a div

###Logging on browser exit

If you want to log out what is left if the user closes the browser, you can hook into the window.onunload function:

    window.onunload = function (event) {
        JSLogger.MakeLog("INFO", "Application", "Browser Unload",
        JSLogger.JSLog.GetData("Browser has been unloaded."), true);
    };

###API

####JSLogger.MakeLog(type,system,operation,jsLoggerData,forceLog) #####function that actually writes the logs

  • type: "INFO","DEBUG","ERROR"
  • system: whatever the parent class/page is that is calling this
  • operation: whatever function/method is calling this
  • jsLoggerData: JSLoggerData object (see below)
  • forceLog: True if you want to write the log immediately, false if it will use the default cache number

####JSLogger.JSLog.GetData(message)

  • message: any error message in string format
  • returns {"message": message }

####JSLogger.JSLog.GetDataFromError(error)

  • error: client side Javascript error object: {number,name,message,description} converted to a string
  • returns {"message": errorAsString}

jslogger's People

Contributors

jasonwilczak avatar

Watchers

James Cloos avatar  avatar

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.