FigmaToCode icon indicating copy to clipboard operation
FigmaToCode copied to clipboard

log: custom logging using `loglevel` & enum `LogLevel`

Open canewsin opened this issue 9 months ago • 7 comments

canewsin avatar Mar 27 '25 04:03 canewsin

Does this help you in any way or is it just code cosmetic?

bernaferrari avatar Mar 27 '25 04:03 bernaferrari

increases code gen speed for large components and frames.

canewsin avatar Mar 27 '25 05:03 canewsin

Via log level? Because there shouldn't be any difference right?

bernaferrari avatar Mar 27 '25 05:03 bernaferrari

yup, codebase has many console.log/warn statements, we may forgot to remove and it's not trival to comment and uncomment all the time while development. with this loglevel variable we can toggle log and can also change that on release builds.

canewsin avatar Mar 27 '25 06:03 canewsin

I like it, sorry if it is slow, I should probably fix that.

If we do something like:

const originalLog = console.log;
console.log = function(...args) {
    originalLog.apply(console, ["Node log:", ...args]);
};

then we don't need to override it everywhere/import everywhere and can be the best of both worlds. I'll try this solution.

bernaferrari avatar Mar 27 '25 14:03 bernaferrari

@bernaferrari

canewsin avatar Mar 28 '25 05:03 canewsin

@bernaferrari pushed with suggested changes

canewsin avatar Mar 28 '25 08:03 canewsin