tslog icon indicating copy to clipboard operation
tslog copied to clipboard

Bug: [BUG]

Open rcl-official opened this issue 1 year ago • 2 comments

Describe the bug I'm using the plasmo framework to write a chrome extension, while i want to introduce the tslog to handle my logging issue. And I found

''' Uncaught TypeError: (0 , _tslog.Logger) is not a constructor '''

rcl-official avatar Aug 22 '24 10:08 rcl-official

More context please on how to reproduce it.

terehov avatar Aug 22 '24 11:08 terehov

I ran into the same problem using plasmo. I ended up having to do something like this to get it to work.. I've not had too much time to dig into why it's needed, but hopefully this helps someone...

import type { ILogObj, Logger as LoggerType } from "tslog";
import * as tslog from "tslog/dist/esm/index.js";

const { Logger } = tslog;

class BrowserLogger {
  contexts: [string, string][];
  logger: LoggerType<ILogObj>;

  constructor(source: ExtensionFileSource) {
    this.logger = new Logger({
      prefix: ['prefix']
    });
  }
}

vernak2539 avatar Feb 10 '25 21:02 vernak2539