Make Logger obey log level settings
#703
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this change, log messages will be suppressed if they are at a lower level than whatever the current log level setting is (i.e., if the setting is
'error', a call tolog.debug(...)will output nothing).Currently the log level is set on a per-logger basis via the
leveloption to theLoggerconstructor.For backwards compatibility until we decide otherwise, if unspecified the level defaults to
'debug', i.e., always print all log messages. However, now that we can obey the level setting, we should probably consider changing the default. We probably should also consider adding an'off'level that suppresses all log output, but for weird complicated reasons having to do with conflation of theconsoleAPI with the level name strings that's tricky. (I'd argue that the default level should either be'error'or'off'.)Eventually we will probably also want to read the setting from an environment variable, but that's an additional bundle of complication that deserves its own issue.
Closes #679
Note
Introduce level-filtering
makeConsoleTransportand removelevelfromLoggeroptions, updating types, dispatch, tests, and consumers.consoleTransportwith level-awaremakeConsoleTransport(level = 'debug').logLevelsfrom array to keyed object;LogLevelis nowkeyof typeof logLevels.levelfromLoggerOptions;parseOptionsdefaults tomakeConsoleTransport().Loggerinternals:#dispatch(options, level, ...args);injectStreamand method bindings passlevelseparately.makeConsoleTransportinstead ofconsoleTransport.makeConsoleTransport; keepmakeStreamTransport/makeArrayTransportunchanged.consoleTransportwithmakeConsoleTransport()in kernel tests and agents.Written by Cursor Bugbot for commit b03545a. This will update automatically on new commits. Configure here.