Coder Social home page Coder Social logo

Comments (4)

gopinaath avatar gopinaath commented on August 16, 2024

I got the same error while building a typescript application. Node:18:14:2, TSC: 5.3.2. MacOS

from tslog.

jandobrx avatar jandobrx commented on August 16, 2024

Same issue here using a custom logger this would be nice to fix!

from tslog.

terehov avatar terehov commented on August 16, 2024

Is it possible, that you have some circular dependencies somewhere? So basically, in the file where you create the root logger to the file where you try to create or consume a sub logger? Have you tried importing tslog instanciating the logger in the same file, where you replaced that logger with console.log? Because effectively it’s exactly what you did by placing console.log inside, since you instanciate it right there without importing a sub logger.
We once ran into a similar problem with tRPC and assumed tslog was the problem, it turned out to be a circular dependency and a Node problem indeed.
If that’s not the case, can you provide me with a repo, that boils down the problem for reproduction? Thx

from tslog.

keystef avatar keystef commented on August 16, 2024

I can't share the full code but I'm not really doing any import magic.

This is my logging config:

import { Logger, ILogObj, ISettingsParam } from 'tslog';

const prettyLogConfig: ISettingsParam<ILogObj> = {...};
const structuredLogConfig: ISettingsParam<ILogObj> = {...};

const formattedLogging: boolean = ['0', 'off', 'false', 'no'].includes(
  String(process.env?.STRUCTURED_LOGS).toLowerCase()
);
const logger: Logger<ILogObj> = new Logger(
  formattedLogging ? prettyLogConfig : structuredLogConfig
);

export { logger };

Then I use it like this:

import { logger } from './logging.js';
...

const objects: MyCustomObject[] = await getMyCustomObjects(getMyCustomObjectsRequest);
console.log(`List objects (console)`, objects);
logger.info(`List objects (logger)`, objects);

from tslog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.