LVM-IT / lvo-logging-lib

Logging facade for different Logging-Backends (Console, LocalStorage, Graylog)
Other
3 stars 0 forks source link
angular lvm oss tossca typescript

@lvo/logging

This project was generated with Angular CLI

npm version Build Status codecov Greenkeeper badge Known Vulnerabilities Dependency Status devDependency Status

Usage

Usage in Code

Dependency Import

npm install @lvo/logging --save-dev 

Module Import

     import { LoggingModule } from '@lvo/logging';

     @NgModule({  
       imports: [
         LoggingModule,
         ...

Logger Construction and Usage

     import { Logger, LogManager } from '@lvo/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 {
        Verbose, // 1
        Debug,   // 2
        Info,    // 3
        Warning, // 4
        Error,   // 5
        Critical // 6
        Quiet    // 7
     }

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 npm run 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 @lvo/logging to execute the unit tests via Karma.

Run ng test @lvo/logging --watch=false --code-coverage 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.

License

The MIT License (MIT)

Licensed By Tossca:

alt text