1.0.2 • Published 5 years ago

yt-angular-logger v1.0.2

Weekly downloads
13
License
-
Repository
-
Last release
5 years ago

yt-angular-logger

This is useful to log your error/info/warning etc. on console, localstorage and server.

How to integrate

Steps: 1. Run "npm i yt-angular-logger" in your angular project. 2. Import it in appModule like: "import { LogModule, LogPublisherConfig } from 'yt-angular-logger'"; 3. Create a configuration variable of LogPublisherConfig class and add it in appmodule.ts file. Set isActive property true/false according to wherever you want to log the content i.e.

            const logConfig: LogPublisherConfig[] = [
                    {
                        "loggerName": "console",
                        "loggerLocation": "",
                        "isActive": true
                    },
                    {
                        "loggerName": "localstorage",
                        "loggerLocation": "logging",
                        "isActive": false
                    },
                    {
                        "loggerName": "webapi",
                        "loggerLocation": "YourDomainName/api/log",
                        "isActive": false
                    }];
                    
4. Replace "YourDomainName/api/log" with your endpoint when you want to log content on server.
5. Use LogModule in your NgModule's Import i.e. 

    LogModule.forRoot(logConfig)              

6. To use it, import LogService in your component. This service will expose all logging functions i.e.

    import { LogService } from 'yt-angular-logger';

7. Add service in your constructor and use it i.e.
    
    constructor(private _LogService: LogService) {
        this._LogService.log('log message from component', { LogObject: 12345 }, "LogText",...more parameters if you want to supply);
        }

#Changes in Version

 # 1.0.1
    Readme file content is updated to guild that how can we implement it.
# 1.0.2
    A few internal changes made to handle errors.