1.0.0 • Published 6 years ago

@invsqr/logging v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
6 years ago

Installation

Using npm:

npm install @invsqr/logging --save

Setup

In your root module (e.g. AppModule):

import { LoggingModule, LoggingService, LogLevel } from "auth";

@NgModule({
	declarations: [
		...
	],
	imports: [
		...
		LoggingModule.forRoot({ apiUrl: "..." }, LogLevel.error, LogLevel.info)
	],
	providers: [
		...
		LoggingService
	],
	bootstrap: [...]
})
export class AppModule { }

LoggingModule.forRoot could, for instance, accept the application's environment file, assuming the environment file contains an apiUrl property.

A second, optional parameter can be passed in to forRoot in order to specify the log upload threshold, which determines at what level of severity a log will be uploaded (defaults to LogLevel.error if not specified).

A third, optional parameter can be passed in to forRoot in order to specify the log intercept threshold, which determines at what level of severity a log will be intercepted (defaults to LogLevel.info if not specified).

Usage

Any console.info, console.log, console.warn or console.error will be intercepted (severity dependent on configuration) by the LoggingService and uploaded to the server (severity dependent on configuration).

There's no need to directly interface with the LoggingService unless the intent is to upload a log to the server while bypassing the console class or the current upload severity configuration. To do so:

import { LogLevel, LoggingService } from "@invsqr/logging";

class ExampleClassPossiblyAComponentOrServiceDoesntMatterJustDontMakeYourClassNamesTooLong {

	constructor(private loggingService: LoggingService) {

		this.loggingService.log(LogLevel.info, "test message");

	}

}

Notes

To use the console object and bypass the LoggingService's interceptor, pass "_" as the first argument:

console.log("_", "this message will be ignored by the LoggingService interceptor");
1.0.0

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago