{"id":13481637,"url":"https://github.com/noemi-salaun/ng-logger","last_synced_at":"2025-09-07T10:05:03.558Z","repository":{"id":11125320,"uuid":"68448456","full_name":"noemi-salaun/ng-logger","owner":"noemi-salaun","description":"Angular logger service","archived":false,"fork":false,"pushed_at":"2023-03-04T02:28:01.000Z","size":1296,"stargazers_count":63,"open_issues_count":20,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T17:44:55.252Z","etag":null,"topics":["angular","angular2","angular8","angular9","log","logger","logging","ng","ng-logger","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noemi-salaun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-17T11:33:45.000Z","updated_at":"2023-09-20T19:27:57.000Z","dependencies_parsed_at":"2024-01-14T13:45:34.682Z","dependency_job_id":"f5c31f2a-6362-4d7e-b945-8988ab4833f9","html_url":"https://github.com/noemi-salaun/ng-logger","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"4804924ed2e3a106656172537cf3d16762fe9994"},"previous_names":["noemi-salaun/ng2-logger"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noemi-salaun%2Fng-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noemi-salaun%2Fng-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noemi-salaun%2Fng-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noemi-salaun%2Fng-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noemi-salaun","download_url":"https://codeload.github.com/noemi-salaun/ng-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":208394956,"owners_count":14859892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","angular2","angular8","angular9","log","logger","logging","ng","ng-logger","typescript"],"created_at":"2024-07-31T17:00:53.575Z","updated_at":"2024-07-31T17:06:36.794Z","avatar_url":"https://github.com/noemi-salaun.png","language":"TypeScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# ng-logger\n\n[![Build Status](https://img.shields.io/travis/noemi-salaun/ng-logger/master.svg?style=flat-square)](https://travis-ci.org/noemi-salaun/ng-logger)\n[![npm version](https://img.shields.io/npm/v/@nsalaun/ng-logger.svg?style=flat-square)](https://www.npmjs.com/package/@nsalaun/ng-logger)\n[![devDependencies Status](https://img.shields.io/david/dev/noemi-salaun/ng-logger.svg?style=flat-square)](https://david-dm.org/noemi-salaun/ng-logger?type=dev)\n[![peerDependencies Status](https://img.shields.io/david/peer/noemi-salaun/ng-logger.svg?style=flat-square)](https://david-dm.org/noemi-salaun/ng-logger?type=peer)\n[![license](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/noemi-salaun/ng-logger/blob/master/LICENSE)\n\n**ng-logger** is a simple Angular logger service that responds to two needs :\n\n - A log level system to be able to disable certain calls as needed. *We do not want to see our debug trace on production.*\n - A logger that keeps trace of the original log call. *We do not want all our logs to be referenced in some `logger.service.js` all the time.*\n\nThis package is compatible with **Angular 12** and above, [Angular AoT compiler](https://angular.io/docs/ts/latest/cookbook/aot-compiler.html) and [Angular CLI](https://cli.angular.io/).\n\n## Installation\n\n### 1 - Install the npm package.\n\n```shell\nnpm install --save @nsalaun/ng-logger\n```\n        \n### 2 - Import `NgLoggerModule` in your application and use `forRoot(level: Level)` to choose your log level :\n\n```typescript\nimport { NgModule }              from '@angular/core';\nimport { BrowserModule }         from '@angular/platform-browser';\nimport { AppComponent }          from './app.component';\nimport { NgLoggerModule, Level } from '@nsalaun/ng-logger';\n     \n@NgModule({\n    imports:      [ BrowserModule, NgLoggerModule.forRoot(Level.LOG) ],\n    declarations: [ AppComponent ],\n    bootstrap:    [ AppComponent ],\n})\nexport class AppModule { } \n```\n\n### 3 - Loading\n\n#### Using SystemJS configuration\n\n```JavaScript\nSystem.config({\n    map: {\n        '@nsalaun/ng-logger': 'node_modules/@nsalaun/ng-logger/bundles/nsalaun-ng-logger.umd.js'\n    }\n});\n```\n\n#### Angular-CLI\n\nNo need to set up anything, just import it in your code.\n\n#### Rollup or webpack\n\nNo need to set up anything, just import it in your code.\n\n#### Plain JavaScript\n\nInclude the `umd` bundle in your `index.html`:\n```html\n\u003cscript src=\"node_modules/@nsalaun/ng-logger/bundles/nsalaun-ng-logger.umd.js\"\u003e\u003c/script\u003e\n```\nand use global `nsalaun.ngLogger` namespace.\n\n### AoT compilation\nThe library is compatible with _AoT compilation_.\nBecause of the new metadata version with Angular 5, the library is not compatible with previous Angular version.\n\n## Usage\n\n### Basic Usage\n\nInject the `Logger` service anywhere you need it and use it like it's `console` :\n \n```typescript\n@Component({})\nexport class MyComponent(){\n\n    constructor(private logger: Logger){\n    \n        this.logger.log('Hello !', \"It's working :)\");\n        \n    }\n}\n```\n\nThe service offer a sub-list of `window.console` capacities :\n\n - Basics :\n     - **[log](https://developer.mozilla.org/en-US/docs/Web/API/Console/log)(...args: any[]) -** Outputs a message to the Web Console.\n     - **[debug](https://developer.mozilla.org/en-US/docs/Web/API/Console/debug)(...args: any[]) -** Outputs a debugging message to the Web Console.\n     - **[info](https://developer.mozilla.org/en-US/docs/Web/API/Console/info)(...args: any[]) -** Outputs an informational message to the Web Console.\n     - **[warn](https://developer.mozilla.org/en-US/docs/Web/API/Console/warn)(...args: any[]) -** Outputs a warning message to the Web Console.\n     - **[error](https://developer.mozilla.org/en-US/docs/Web/API/Console/error)(...args: any[]) -** Outputs an error message to the Web Console.\n     \n - Groups :\n     - **[group](https://developer.mozilla.org/en-US/docs/Web/API/Console/group)(groupTitle: string) -** Creates a new inline group in the Web Console log.\n     - **[groupCollapsed](https://developer.mozilla.org/en-US/docs/Web/API/Console/groupCollapsed)(groupTitle: string) -** Creates a new inline group in the Web Console log that is initially collapsed.\n     - **[groupEnd](https://developer.mozilla.org/en-US/docs/Web/API/Console/groupEnd)() -** Exits the current inline group in the Web Console.\n     \n - Time :\n     - **[time](https://developer.mozilla.org/en-US/docs/Web/API/Console/time)(timerName: string) -** Starts a timer you can use to track how long an operation takes. It works only with log `Level` equal or higher than `DEBUG`.\n     - **[timeEnd](https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd)(timerName: string) -** Stops a timer that was previously started by calling `Logger.time()`. It works only with log `Level` equal or higher than `DEBUG`.\n     \n### Using different log level on developpment or production\n\nTo set a different log level depending on environment, you can proceed as follows:\n\n```typescript\nimport { NgModule, isDevMode }   from '@angular/core';\nimport { BrowserModule }         from '@angular/platform-browser';\nimport { NgLoggerModule, Level } from '@nsalaun/ng-logger';\nimport { AppComponent }          from './app.component';\n\n// Set different log level depending on environment.\nconst LOG_LEVEL = Level.LOG;\nif (!isDevMode()) {\n    const LOG_LEVEL = Level.ERROR;\n}\n \n@NgModule({\n    imports     : [ BrowserModule, NgLoggerModule.forRoot(LOG_LEVEL) ],\n    declarations: [ AppComponent ],\n    bootstrap   : [ AppComponent ],\n})\nexport class AppModule { } \n```\n\n*Please note this method is one among others. It may not suit your projects requirements/constraints*\n     \n## License\n\n© 2017-2021 Noémi Salaün\n\n[MIT](https://github.com/noemi-salaun/ng-logger/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoemi-salaun%2Fng-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoemi-salaun%2Fng-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoemi-salaun%2Fng-logger/lists"}