ProductPromotion
Logo

Angular.JS

made by https://0x3d.site

GitHub - dbfannin/ngx-logger: Angular logger
Angular logger. Contribute to dbfannin/ngx-logger development by creating an account on GitHub.
Visit Site

GitHub - dbfannin/ngx-logger: Angular logger

GitHub - dbfannin/ngx-logger: Angular logger

npm version

NGX Logger

NGX Logger is a simple logging module for angular (currently supports angular 6+. Warning : you might need older version of the lib to use older versions of angular). It allows "pretty print" to the console, as well as allowing log messages to be POSTed to a URL for server-side logging.

Join the NGX Logger discord server!

Join our discord server! Get updated on the latest changes and newest feature! Get help faster from the community! Share implementation strategies! Make friends :)

Installation

npm install --save ngx-logger

Once installed you need to import our main module (optionally you will need to import HttpClientModule):

import { LoggerModule, NgxLoggerLevel } from "ngx-logger";
// HttpClientModule is only needed if you want to log on server or if you want to inspect sourcemaps
import { HttpClientModule } from "@angular/common/http";

The only remaining part is to list the imported module in your application module, passing in a config to initialize the logger.

@NgModule({
  declarations: [AppComponent, ...],
  imports:
  [
    // HttpClientModule is only needed if you want to log on server or if you want to inspect sourcemaps
    HttpClientModule,
    LoggerModule.forRoot({
      serverLoggingUrl: '/api/logs',
      level: NgxLoggerLevel.DEBUG,
      serverLogLevel: NgxLoggerLevel.ERROR
    }),
    ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Usage

To use the Logger, you will need to import it locally, then call one of the logging functions

import { Component } from "@angular/core";
import { NGXLogger } from "ngx-logger";

@Component({
  selector: "your-component",
  templateUrl: "./your.component.html",
  styleUrls: ["your.component.scss"],
})
export class YourComponent {
  constructor(private logger: NGXLogger) {
    this.logger.error("Your log message goes here");
    this.logger.warn("Multiple", "Argument", "support");
  }
}

For most browsers, you need to enable "verbose" or "debug" mode in the developper tools to see debug logs

Configuration

Configuration is sent by the forRoot call LoggerModule.forRoot({level: NgxLoggerLevel.DEBUG})

For more information about configuration see the doc

Customise logger behavior

Since version 5 NGXLogger is fully customisable

See how in the doc

Features

You can see more of the features supported by NGXLogger in this doc

Demo App

There is a demo application with examples of how to use ngx-logger. To run it perform the following:

  • Clone the repo
  • Run npm ci or npm install
  • Build ngx-logger using ng build
  • Run ng serve demo to serve the app

A convenience script has been added to package.json that performs the above steps. Simply run npm run demo to have the demo built and served.

Dependencies

  • @angular/common
  • @angular/core

Testing Your App When Using NGXLogger

If you inject any of the NGX Logger services into your application, you will need to provide them in your Testing Module.

To provide them in your Testing Module:

import { LoggerTestingModule } from 'ngx-logger/testing';

TestBed.configureTestingModule({
  imports: [
    LoggerTestingModule
  ],
  ...
});

All services have mocked classes that can be used for testing located here

Contribute

All are welcome to contribute to NGX Logger.

See the doc to know how

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory