Code Monkey home page Code Monkey logo

ng-log's Introduction

Angular Logging, Analytics and Telemetry Service

GitHub Actions Status Azure Pipelines Status codecov npm version Gitter

Vendor-agnostic logging, analytics and telemetry service abstractions and some implementations for Angular applications.

Features

  • Log service provides both application scoped root logger and category scoped child loggers with createLogger(categoryName) method.
  • Category scoped child loggers can be destroyed with destroyLogger(categoryName) method
  • Supports both standard logging api (trace, debug, info, warn, error, fatal) and telemetry tracking api (trackPageView, trackEvent, etc.)
  • Support measuring user timings for events and page views with startTrackEvent, stopTrackEvent, startTrackPage and stopTrackPage
  • Extendable and plugable logging providers (see built-in ConsoleLoggerProvider for implementation demo)
  • Flexable logging configuration
  • Latest version of Angular and compatible with server side rendering (SSR / Angular Universal)

Getting Started

Installation

npm

npm install @dagonmetric/ng-log

or yarn

yarn add @dagonmetric/ng-log

Module Setup (app.module.ts)

The following code is a simple module setup with ConsoleLoggerModule.

import { LogModule } from '@dagonmetric/ng-log';
import { ConsoleLoggerModule } from '@dagonmetric/ng-log/console';

@NgModule({
  imports: [
    // Other module imports

    // ng-log modules
    LogModule.withConfig({ minLevel: 'debug' }),
    ConsoleLoggerModule
  ]
})
export class AppModule { }

See log-config.ts source file to learn more about options for LogModule.

Live edit app.module.ts in stackblitz

Usage (app.component.ts)

import { Component, OnInit } from '@angular/core';

import { LogService } from '@dagonmetric/ng-log';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
  constructor(private readonly logService: LogService) { }

  ngOnInit(): void {
    // Track traces
    this.logService.trace('Testing trace');
    this.logService.debug('Testing debug');
    this.logService.info('Testing info');
    this.logService.warn('Testing warn');

    // Track exceptions
    this.logService.error(new Error('Testing error'));
    this.logService.fatal(new Error('Testing critical'));

    // Track page view
    this.logService.trackPageView({
      name: 'My Angular App',
      uri: '/home'
    });

    // Track custom event
    this.logService.trackEvent({
      name: 'video_auto_play_start',
      properties: {
        non_interaction: true
      }
    });

    // Create child logger with category name
    const childLogger = this.logService.createLogger('component1');

    // Log with child logger
    childLogger.info('Testing info');

    // Destroy child logger
    this.logService.destroyLogger('component1');
  }
}

Live edit app.component.ts in stackblitz

Samples

Sub-modules

Integrations

Related Projects

  • ng-config - Configuration & options service for Angular applications
  • ng-cache - Caching service for Angular applications

Build & Test Tools

We use lib-tools for bundling, testing and packaging our library projects.

Lib Tools

Feedback and Contributing

Check out the Contributing page.

License

This repository is licensed with the MIT license.

ng-log's People

Contributors

dagonmetric-contributor avatar mmzliveid avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

msspdev

ng-log's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm protractor Unavailable

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency eslint-plugin-jsdoc to ^39.9.1
  • Update dependency eslint-plugin-prettier to ^4.2.1
  • Update dependency jasmine-core to ^4.6.1
  • Update dependency rxjs to ^7.8.1
  • Update dependency ts-node to v10.9.2
  • Update dependency tslib to ~2.6.3
  • Update dependency zone.js to ^0.14.10
  • Update dependency @types/jasmine to v5
  • Update dependency @types/node to v20
  • Update dependency eslint to v9
  • Update dependency eslint-config-prettier to v9
  • Update dependency eslint-plugin-jsdoc to v50
  • Update dependency eslint-plugin-prettier to v5
  • Update dependency jasmine-core to v5
  • Update dependency prettier to v3
  • Update dependency typescript to v5
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @angular/common ^11.2.14
  • @angular/core ^11.2.14
  • rxjs ^7.5.5
  • tslib ~2.4.0
  • @angular-devkit/build-angular ^12.2.17
  • @angular/cli ^11.2.19
  • @angular/compiler ^11.2.14
  • @angular/compiler-cli ^11.2.14
  • @angular/language-service ^11.2.14
  • @angular/platform-browser ^11.2.14
  • @angular/platform-browser-dynamic ^11.2.14
  • @types/jasmine ^4.0.3
  • @types/jasminewd2 ^2.0.10
  • @types/node ^16.11.36
  • @typescript-eslint/eslint-plugin ^4.33.0
  • @typescript-eslint/parser ^4.33.0
  • eslint ^7.32.0
  • eslint-config-prettier ^7.2.0
  • eslint-plugin-jsdoc ^39.3.2
  • eslint-plugin-prettier ^4.0.0
  • jasmine-core ^4.1.1
  • lib-tools ^2.0.4
  • prettier ^2.2.1
  • protractor ~7.0.0
  • ts-node ^10.8.0
  • tsickle ^0.39.1
  • typescript 4.1.5
  • zone.js ^0.11.5
samples/demo-app/package.json
  • @angular/animations 11.2.14
  • @angular/common ^11.2.14
  • @angular/compiler 11.2.14
  • @angular/core ^11.2.14
  • @angular/forms ^11.2.14
  • @angular/platform-browser ^11.2.14
  • @angular/platform-browser-dynamic ^11.2.14
  • @angular/router ^11.2.14
  • @dagonmetric/ng-log ^2.3.3
  • rxjs ^7.5.5
  • tslib ~2.4.0
  • zone.js ^0.11.5
  • @angular-devkit/build-angular ^12.2.17
  • @angular/cli ^11.2.19
  • @angular/compiler-cli ^11.2.14
  • @angular/language-service ^11.2.14
  • @types/node ^16.11.36
  • ts-node ~10.8.0
  • typescript ~4.1.5

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.