Code Monkey home page Code Monkey logo

console-logger's Introduction

console-logger

Features

  1. Simple browser console logging
  2. Show log data on your html page
  3. View log history
  4. Central on/off facility
  5. Send log data to remote server
  6. Export data in csv format (only for supported browser's)

Hidden Features:

  1. Use as an Angularjs service
  2. No dependency to jQuery or any other library
  3. Uses localStorage of HTML5 if available
  4. Uses JSON and fallbacks to forms in old browsers
  5. CORS supported
  6. almost supported to every available browser

How to do ?

  1. Init: Let's do some config

    var loggerObj = new consoleLogger.logger(); //by default its true

    var loggerObj = new consoleLogger.logger(false); //if don't want to log (eg: in prod)

    //if you want to log as an html

    var loggerObj = new consoleLogger.logger(true,true); //second argument is for log as an html, default is false

    /Note: you can use "on/off" in place of true/false/

  2. Use: one liner's piece of cake !!

a) DEBUG

loggerObj.debug('this is a debug log');
//or
loggerObj.debug(e); //e => error object

b) FATAL

loggerObj.fatal('this is a fatal log');
//or
loggerObj.fatal(e); //e => error object

a) ERROR

loggerObj.error('this is a error log');
//or
loggerObj.error(e); //e => error object

a) WARN

 loggerObj.warn('this is a warn log');
 //or
 loggerObj.warn(e); //e => error object
  1. View log history:

    loggerObj.history();

  2. Send Data to server (config):

    //configure your logger object

    var loggerObj = new consoleLogger.logger(true,false,{url:'testUrlHere',toSend:2});

    /*second argument is for log as an html *third argument is config for sending data for remote server *Config example => {url:'testurl',toSend:'1 or 2',headers:'any custom ajax headers default is json'} *toSend=1 => send only error and fatal *toSend=2 => send all logs *even if logging is false then also data will be sent to server */

  3. Use As an Angularjs Service

a) Register the module dependency and do some configuration

var app =angular.module('logTest',['consoleLogger']).run(function (loggerService) {

loggerService.config(true, false, {url: 'testUrlHere', toSend: 2})
/* fatal,error :1 , all:2
 * see point 4 for config options
 */
loggerService.error('Error from run')
});

b) Use same as point 2 above inside controller or services

app.controller('demoController',function($scope,loggerService){

loggerService.debug('this is a debug log');
loggerService.error('this is a error log');
loggerService.history(); //to see log history

});
  1. Export data in csv format:

    a) If your log as html is true than you can export the log data to client machine in .csv format
    b) To use export feature you need to include filesaver.js to your project
    c) IE >=10, chrome-1 ,firefox -1 , safari -1 ,opera -1 are supported

Browser compatibility:

IE 6+(6-7 don't have console but still you can send logs)
All other browser's that support >= ECMAScript 3.

Note:

  • IE6 to IE8 json2/json3.js (sorry can't help it. If it's not present then transport will fallback to form)

Contribute

  • clone the repo
  • run npm install in bash or anywhere,to install the necessary node packages
  • to compile typeScript use 'gulp build'
  • to watch use 'gulp'

console-logger's People

Contributors

pranaydutta89 avatar

Watchers

 avatar

console-logger's Issues

use local storage (html5)

use local storage while storing the log history data , since on page reload the JavaScript array will be flushed and we can't afford that

organize code

organize the code according to functionality/domain especially angularLogger.ts

node API's

create node apis to test post data from logger

check IE version

check via ie version rather checking by whether object is undefined

support for dojo

need to use dojo functions for ajax request if dojo is present

add support for angular service

support to send data to remote server via $http service which if not present then fall backs to $.ajax and option for user to choose

allow cors

cors is not enabled while sending the data,enable it

regression

do a regression test for every process

update document

update the document with the new features included and use of the same

batch posting in server

at present every log is posted to server , what we want is to post the log in batches of 10 or 20 configurable by the user

developer's readme

create a developer readme ,in which steps would be there to compile and build the code

transport evaluator

since many js libraries can be included like jQuery,dojo etc we need to have a transport function to evaluate what is the appropriate way to send an ajax request to server

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.