1.0.2 • Published 7 years ago
@ng-lv/logging v1.0.2
@ng-lv/logging
Usage
Usage in Code
Dependency Import
npm install @ng-lv/logging --save-dev
or add to package.json
"dependencies": { "@ng-lv/logging": "1.0.0" }
Module Import
import { LoggingModule } from '@ng-lv/logging';
@NgModule({
imports: [
LoggingModule,
...
Logger Construction and Usage
import { Logger, LogManager } from '@ng-lv/logging';
@Injectable()
export class AClassWithLogging {
private logger: Logger;
constructor(private logManager: LogManager) {
// create Logger with Class Context
this.logger = logManager.getLogger(this);
// create logger with Context Hierarchy
// now you are able to switch all Logger in context ['c1','c2'] to debug level for example
this.logger.debug(['c1','c2','c3']);
// use Logger
this.logger.debug('Hello ..');
}
Access to the Logging Facility via Browser Console
LogManager : log.logmanager
registered Logger : log.map
set log level : log.logmanager.setCurrentLogLevel(4, ['c1','c2'])
export enum LogLevel {
Nothing, // 0
Verbose, // 1
Debug, // 2
Info, // 3
Warning, // 4
Error, // 5
Critical // 6
}
Development server
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Build
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the -prod
flag for a production build.
Running unit tests
Run ng test
to execute the unit tests via Karma.
Run ng test --code-coverage --single-run
to create a test coverage Report
Running end-to-end tests
Run ng e2e
to execute the end-to-end tests via Protractor.
Before running the tests make sure you are serving the app via ng serve
.