New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@blaugold/angular-logger

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blaugold/angular-logger

Logger for Angular 2 Apps.

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Angular Logger

CircleCI

npm version

Logger for Angular 2 Apps.

Installation

    npm i --save @blaugold/angular-logger

Usage

Include the LoggerModule and the ConsoleWriterModule at the root module.

@NgModule({
    imports: [
        LoggerModule.forStd(),
        ConsoleWriterModule.forRoot()
    ]
})
export class AppModule {
}

In your components, directives, pipes and services get the Logger through DI.

@Injectable()
export class MyService {

    constructor(private log: Logger) {}
    
    getSome() {
        this.log.trace('Getting something for MyService')
    }
}

To change the log level at which the logger emits logs, type in the console logat.trace to set the logger to log level Trace for example. Per default the logger is set to Info. You can also permanently change the log level:

    LoggerModule.forStd(new LoggerDef().level(LogLevel.Warn))

Noop Logger

When testing classes which use a logger, but you are not interested in what is logged, add LoggerModule.forStd() to the testing module. As long as there is no log consumer like the ConsoleWriterModule imported the LoggerModule will inject a noop logger for the Logger token.

Package Logger

Packages which are included in other apps to provide some functionality can make use of aux loggers in their classes:

    export const myPkgLogger = new LoggerDef('MyPkg')
    
    @Injectable()
    export class MyService {
        constructor(@Inject(myPkgLogger) log: Logger) {
            log.info('MyService was instantiated')
        }
    }
    
    @NgModule({
        imports: [
            LoggerModule.forAux([myPkgLogger])
        ]
    })
    export class MyPkgModule {
    }

Consumers of this package can use myPkgLogger to set the log level of the package's logger. If the consuming app or package does not register a LogConsumer the classes are injected with a noop logger.

Keywords

FAQs

Package last updated on 06 Nov 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc