forked from nmccready/angular-simple-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.json
1 lines (1 loc) · 6.93 KB
/
params.json
1
{"name":"Angular-simple-logger","tagline":"Basic log level logging with independent loggers.","body":"angular-simple-logger (nemLogging.nemSimpleLogger)\r\n==============\r\n\r\n[![Join the chat at https://gitter.im/nmccready/angular-simple-logger](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nmccready/angular-simple-logger?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\r\n[![Dependencies](https://david-dm.org/nmccready/angular-simple-logger.png)](https://david-dm.org/nmccready/angular-simple-logger) \r\n[![Dependencies](https://david-dm.org/nmccready/angular-simple-logger.png)](https://david-dm.org/nmccready/angular-simple-logger) \r\n[![Build Status](https://travis-ci.org/nmccready/angular-simple-logger.png?branch=master)](https://travis-ci.org/nmccready/angular-simple-logger)\r\n\r\n\r\n### Purpose:\r\nTo have simplified log levels where a supporting angular module's log levels are independent of the application.\r\n\r\n### Dependencies: (What can make what was simple/complicated (kinda))\r\n\r\nHow to decide which file from `/dist` to include in your project:\r\n\r\n- If using `bower`, include `dist/angular-simple-logger.js`. This is a drop-in replacement for `browser.js`. It is prepacked (all dependencies included). Do NOT use with Browserify or Webpack since it will break any commonJS compiler.\r\n\r\n- If using `npm` with Browserify or Webpack, include `dist/index.js` (CommonJS version). Do NOT use with bower.\r\n\r\n- *.light.js - any, will/should work with Browser, Brower and npm (with some love, but why?)\r\n\r\nWhy is it this way? Well visonmedia debug is complicated. See [here](https://github.com/tombatossals/angular-leaflet-directive/issues/997) . I am open to a better way so please work with me, not against me.\r\n\r\n**Bottom line**: Here is what I recommend. If your using bower with a project that depends on this; bundle your vendor files seperatley via gulp, and main bowerfiles. Browserify, and Webpack can work with both bower and npm at the same time so it is up to you to make your whole app play nice (ie you can ignore stuff and not call require).\r\n\r\nAlso you can override which version (say point to*.light.js) for webpack and or browserify to use/target against. \r\n\r\nIf your lucky and all of your projects are in npm then you can eliminate bower and not worry about this.\r\n\r\nIn the end there are plenty of workarounds using the tools explained above.\r\n\r\n### Basic use:\r\n\r\n```js\r\nangular.module('someApp', ['nemLogging'])\r\n//note this can be any type of injectable angular dependency (factory, service.. etc)\r\n.controller(\"someController\", function ($scope, nemSimpleLogger) {\r\n nemSimpleLogger.doLog = true; //default is true\r\n nemSimpleLogger.currentLevel = nemSimpleLogger.LEVELS.debug;//defaults to error only\r\n}); \r\n```\r\n\r\n### Create a Custom Independent Loggers\r\n*(maybe 3 for one lib)*\r\n\r\n```js\r\nangular.module('someApp', ['nemLogging'])\r\n//note this can be any type of injectable angular dependency (factory, service.. etc)\r\n.service(\"apiLogger\", function ($scope, nemSimpleLogger) {\r\n var logger = nemSimpleLogger.spawn();\r\n logger.currentLevel = logger.LEVELS.warn;\r\n return logger;\r\n})\r\n.service(\"businessLogicLogger\", function ($scope, nemSimpleLogger) {\r\n var logger = nemSimpleLogger.spawn();\r\n logger.currentLevel = logger.LEVELS.error;\r\n return logger;\r\n})\r\n.service(\"terseLogger\", function ($scope, nemSimpleLogger) {\r\n var logger = nemSimpleLogger.spawn();\r\n logger.currentLevel = logger.LEVELS.info;\r\n return logger;\r\n});\r\n```\r\n\r\n### Use your new creations!\r\n\r\n```js\r\nangular.module('someApp', ['nemLogging'])\r\n//note this can be any type of injectable angular dependency (factory, service.. etc)\r\n.service(\"booksApi\", function (apiLogger, $http) {\r\n //do something with your books\r\n $http.get(\"/ap/books\").then(function(data){\r\n apiLogger.debug(\"books have come yay!\");\r\n });\r\n})\r\n.controller(\"businessCtrl\", function ($scope, businessLogicLogger, book) {\r\n businessLogicLogger.debug(\"new book\");\r\n var b = new book();\r\n $scope.books = [b];\r\n})\r\n.controller(\"appCtrl\", function ($rootScope, terseLogger) {\r\n $rootScope.$on \"error\", function(){\r\n terseLogger.error(\"something happened\");\r\n }\r\n});\r\n```\r\n\r\n### Override all of $log (optional decorator)\r\n\r\nOptionally (default is off) decorate $log to utilize log levels globally within the app.\r\n\r\nNote this logger's currentLevel is debug! Where the order is debug, info, warn, error, log.\r\n\r\n```js\r\nangular.module('someApp', ['nemLogging']))\r\n.config(function($provide, nemSimpleLoggerProvider) {\r\n return $provide.decorator.apply(null, nemSimpleLoggerProvider.decorator);\r\n})\r\n.config(function($provide, nemSimpleLoggerProvider) {\r\n var logger = $provide.decorator.apply(null, nemSimpleLoggerProvider.decorator);\r\n //override level at config\r\n logger.currentLevel = logger.LEVELS.error;\r\n return logger;\r\n})\r\n.run(function($log){\r\n //at run time\r\n //override the default log level globally\r\n $log.currentLevel = $log.LEVELS.error;\r\n});\r\n```\r\n\r\n### Optional Debug Levels via [debug](https://github.com/visionmedia/debug)\r\n\r\nIf you choose to use the [full version of this library](./dist/angular-simple-logger.js) and no the [light](./dist/angular-simple-logger.light.js).\r\n\r\nYou can add finer grain debug levels via the [visionmedia/debug API](https://github.com/visionmedia/debug).\r\n\r\nTo use:\r\n\r\n```js\r\nangular.module('someApp', ['nemLogging']))\r\n//as a provider\r\n.config(function(nemDebugProvider) {\r\n var debug = nemDebugProvider.debug;\r\n debug.enable(\"worker:*\");\r\n})\r\n.service('LoggerLevelA', function(nemSimpleLogger) {\r\n //will have debug, info, warn, error, and log at disposal as before, but now debug is using the visionmedia/debug fn\r\n return nemSimpleLogger.spawn(\"worker:a\");\r\n})\r\n.service('LoggerLevelB', function(nemSimpleLogger) {\r\n return nemSimpleLogger.spawn(\"worker:b\");\r\n})\r\n//heck maybe you don't want all of the logger interface only want debug.. then\r\n.service('JustDebugC',function(nemDebug) {\r\n return nemDebug(\"worker:c\");\r\n})\r\n.run(function(nemDebug){\r\n //enable another debug level\r\n nemDebug.enable(\"coolStuff:*\");\r\n});\r\n```\r\n\r\n### API\r\nUnderneath it all it is still calling `$log` so calling the logger for logging itself is the same.\r\n\r\n- LEVELS: available are `debug, info, warn, error, log`\r\n\r\n- doLog (boolean) - deaults to true. If set to false all logging for that logger instance is disabled.\r\n\r\n- currentLevel (number) - defaults to `error: 4` corresponds to the current log level provided by `LEVELS`.\r\n\r\n- spawn - create a independent logger accepts a logger or a string (see visionmedia debug notes above). Defaults to $log\r\n","google":"UA-72902950-1","note":"Don't delete this file! It's used internally to help with page regeneration."}