Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue regarding POST #1

Open
ArpithaGMGowda opened this issue Feb 22, 2020 · 0 comments
Open

issue regarding POST #1

ArpithaGMGowda opened this issue Feb 22, 2020 · 0 comments

Comments

@ArpithaGMGowda
Copy link

File = MyLoggerMonitor.ts

import {NGXLoggerMonitor, NGXLogInterface} from 'ngx-logger';
import { HttpClient } from '@angular/common/http';
export class MyLoggerMonitor implements NGXLoggerMonitor {
  private _url = 'src/app/log1.log';    // storing in local file
  constructor(private httpClient: HttpClient) { }

 onLog(log: NGXLogInterface,) {
// 1. format the log however you wish it to be formatted
const formattedLog: string = log.message + log.timestamp;

// 2. Make the HTTP Request
this.httpClient.post(this._url, formattedLog).subscribe((data:any)=>{
  console.log('myCustomLoggerMonitor', data);
});
 }
}

File : test1.component.ts

import { Component, OnInit } from '@angular/core';
import { NGXLogger } from '../logger.service';
import { MyLoggerMonitor } from '../my-logger-monitor';

@Component({
  selector: 'app-test1',
  templateUrl: './test1.component.html',
  styleUrls: ['./test1.component.css']
})
export class Test1Component implements OnInit {
  constructor(private logger:NGXLogger) {
 this.logger.registerMonitor(new MyLoggerMonitor());   
    this.logger.error('BLAHBLAHBLAH');
  }

  ngOnInit() {}
}

// i am getting error like

 ERROR in src/app/test1/test1.component.ts:19:31 - error TS2554: Expected 1 arguments, but got 0.    
    19   this.logger.registerMonitor(new MyLoggerMonitor());             
      src/app/my-logger-monitor.ts:10:15
        10   constructor(private httpClient: HttpClient) {
        An argument for 'httpClient' was not provided.

Thank you in advance :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant