Socket
Book a DemoInstallSign in
Socket

@cloudflight/angular-logger

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudflight/angular-logger

0.8.0
latest
npmnpm
Version published
Weekly downloads
31
-56.94%
Maintainers
0
Weekly downloads
 
Created
Source

angular-logger

@cloudflight/angular-logger

Angular wrapper for @cloudflight/logger.

Installation

npm install --save @cloudflight/angular-logger
# or
yarn add @cloudflight/angular-logger
# or
pnpm add @cloudflight/angular-logger

Usage

Logger injection

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

@Component({})
class HAL {
    public constructor(private readonly logger: Logger) {}

    public apoligize() {
        this.logger.info('HAL', `I'm sorry Dave. I'm afraid I can't do that.`);
    }
}

Module setup

import {NgModule} from '@angular/core';
import {LoggerModule} from '@cloudflight/angular-logger';

@NgModule({
    imports: [
        LoggerModule.forRoot({
            consumers: [
                // ...
            ],
        }),
    ],
})
class AppModule {}

Replacing the logger instance

import {NgModule} from '@angular/core';
import {globalLogger, LogConsumer, Logger} from '@cloudflight/angular-logger';

@NgModule({
    providers: [
        // this is the default
        {
            provide: Logger,
            useValue: globalLogger,
        },
    ],
})
class MyModule {}

Adding custom consumers outside the module setup

import {APP_INITIALIZER, NgModule} from '@angular/core';
import {LogConsumer, Logger} from '@cloudflight/angular-logger';

@NgModule({
    providers: [
        MyConsumerClass,
        {
            provide: APP_INITIALIZER,
            useFactory: (logger: Logger, consumer: MyConsumerClass) => () => {
                logger.addConsumer(consumer);
            },
            deps: [Logger, MyConsumerClass],
            multi: true,
        },
    ],
})
class MyModule {}

Keywords

angular-logger

FAQs

Package last updated on 26 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.