feat: add configurable log levels via env.logLevel#1507
feat: add configurable log levels via env.logLevel#1507taronsung wants to merge 7 commits intohuggingface:v4from
Conversation
|
Hi @taronsung 👋 Thanks for the PR! I do like this feature, and it's definitely something I think we can implement. Since we're in the process of a relatively large refactor (v4: https://github.com/huggingface/transformers.js/tree/v4), could you update the base to be that branch? From the looks of it, it'd just entail moving the new files into the We could also take inspiration from the python transformers library... maybe implementing methods like |
Add LogLevel enum and env.logLevel configuration to control library verbosity. Create logger utility that respects the configured log level. Replace console.log/warn calls in pipelines with logger methods. Rebased onto v4 branch and moved files to packages/transformers folder. Closes huggingface#117
58097d9 to
af0f0d4
Compare
nico-martin
left a comment
There was a problem hiding this comment.
I added some commits to the PR. Most of it is just more console. that I wanted to replace with logger., but I also added a mapping between our own logLevels and the ONNX_ENV.logLevel.
| // Environment variables | ||
| export { env } from './env.js'; | ||
| export { env, LogLevel } from './env.js'; | ||
| export { logger } from './utils/logger.js'; |
There was a problem hiding this comment.
Is there a reason you want to export the logger? In my opinion that should stay in the library and should not be user facing.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Summary
Adds configurable logging levels to control library verbosity, as requested in #117.
Changes
LogLevelenum with NONE, ERROR, WARNING, INFO, DEBUG levelsenv.logLevelconfiguration (defaults to WARNING)loggerutility that respects the configured log levelconsole.log/warncalls inpipelines.jsto useloggerLogLevelandloggerfrom main entry pointUsage
Notes
pipelines.jsas a starting pointconsole.warn/errorcalls can be migrated in follow-up PRsTextStreameroutput instreamers.jswas intentionally not changed as it's user-facing streaming output, not loggingCloses #117