NG2 Logger
NG2 Logger is a simple logging module for angular 2. It allows "pretty print" to the console, as well as allowing log messages to be POSTed to a URL for server-side logging.
Dependencies
- @angular/common
- @angular/core
- @angular/http
- moment
Installation
npm install --save ng2.logger
Once installed you need to import our main module:
;
The only remaining part is to list the imported module in your application module, passing in a config to intialize the logger.
@
Usage
To use the Logger, you will need import it locally, then call one of the logging functions
;; @ { thislogger; };
Config Options
- serverLogLevel - Only sends logs to the server for the level specified or higher
- serverLoggingUrl - URL to POST logs
- level: The log level. The app will only log message for that level or higher (OFF disables the logger)
TRACE|DEBUG|INFO|LOG|WARN|ERROR|OFF
Server Side Logging
If serverLogginUrl exists, NG2 Logger will attempt to POST that log to the server.
Payload Example
{level: 'DEBUG', message: 'Your log message goes here'}