8000 GitHub - GotanDev/gkjs-log: Simple JS Logger
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

GotanDev/gkjs-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS Logger

Simple JS Logger.
Allow you to manage logging in Javascript browser console.
In replacement of console.log using for quality and configuration purpose.

  • Easy to use
  • No dependency.
  • 4 Ko only
  • 2 minutes setup
  • "Framework agnostic": can work on pretty much all libraries

Inspired by Log4J.

Usage

You have can use logger with following logging level with associated method

  1. trace (default level, if configuration not set)
    Provide full stack strace

logger.trace("my message");

  1. debug
  2. info
  3. warn
  4. error / fatal

Logging messages will be displayed in differents colors, depends on the criticity level.

capture

It will provide details about message origin location and give stack trace for message :

trace

Disclaimer

gkjs-log provide optionnal feature to display warning about console usage for end-users. end-user-warning

You can personnalize message by

  • using _config.logger.messages configuration settings
  • using GKJS.i18n features on AppTitle and ConsoleWarning codes

personnalized disclaimer

Configuration

On applicaton bootstrap, you have to provide _config global variable with following properties

var _config = {
  /* Debug mode activation. */
  debug: true, 

  logger: {
    /** Configure log level
     * 1 : Trace
     * 2 : Debug
     * 3 : Info
     * 4 : Warn
     * 5 : Error
    **/
 	level:2, 
 	/* Display console disclaimer */
 	disclaimer: true,
 	/* Optionnal */
 	messages: {
 		appTitle: "<my-title>",
 		consoleWarning: "MyWarning"
 	}
  }
}

Dynamic activation

You can activate logger in production environment just by typing following instruction

logger.activeDebugMode() 

Usefull for bug analysis in production environments.

Browser compliancy

Based on console javascript object feature

  • Does not work on old browsers
  • Library does not trigger any exception with old browsers which not provide console JS object.

License

Free to use.
Apache2 License

0