pimterry/loglevel

No log output

ed4becky opened this issue · 2 comments

I am trying to use loglevel in an angular. I have abstracted the service (I don't think that's relevant), and whenthe service is created, a console.log shows output but loglevel does not.

import {Injectable} from '@angular/core';
import {Logger} from './logger.service';
import * as loglevel from 'loglevel';

const noop = (): any => undefined;

@Injectable ({
  providedIn: 'root'
})
export class LogLevelLoggerService implements Logger {
  constructor () {
    console.log(JSON.stringify(loglevel.getLoggers()));
    loglevel.info(''this never gets logged);
  }
  info (msg: string) {
    loglevel.info (msg);
  }
}

I feel like something simple is missing...

Have you set the log level? It defaults to warn, so only warn & error messages will appear, and info messages (like these) will be hidden.

You can change that with loglevel.setLevel("info") (or trace/debug, just a level that's not higher than info), or loglevel.enableAll() which will show all messages.

That was the issue, I thought the default was info.

Thanks for quick response