Uh oh!
There was an error while loading. Please reload this page.
Rewrite the friendly log handler - #1038
Conversation
It wasn't working because it deferred to the regular `slog.TextHandler` for the `WithAttr` and `WithGroup` functions. Both of these functions don't mutate the handler but return a new one. When the top level logger called one of these, log records in that context used the standard handler instead of ours. To implement tracking of attrs and groups, I followed the guide at https://github.com/golang/example/blob/master/slog-handler-guide/README.md for writing custom handlers.
pietern
commented
Dec 1, 2023
pietern
commented
Dec 1, 2023
I made the colors a bit more muted compared to the previous friendly logger, to try and emphasize the log message over the log attributes. The current implementation uses the same approach as |
pietern
commented
Dec 1, 2023
pietern
commented
Dec 1, 2023
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pietern
commented
Dec 1, 2023
Tweaked the colors of the message and attributes a bit more. For multiline messages (like the ones logged by the SDK), the |
CLI: * Add documentation for positional args in commands generated from the Databricks OpenAPI specification ([#1033](#1033)). * Ask for host when .databrickscfg doesn't exist ([#1041](#1041)). * Add list of supported values for flags that represent an enum field ([#1036](#1036)). Bundles: * Fix panic when bundle auth resolution fails ([#1002](#1002)). * Add versioning for bundle templates ([#972](#972)). * Add support for conditional prompting in bundle init ([#971](#971)). * Pass parameters to task when run with `--python-params` and `python_wheel_wrapper` is true ([#1037](#1037)). * Change default_python template to auto-update version on each wheel build ([#1034](#1034)). Internal: * Rewrite the friendly log handler ([#1038](#1038)). * Move bundle schema update to an internal module ([#1012](#1012)). Dependency updates: * Bump github.com/databricks/databricks-sdk-go from 0.26.0 to 0.26.1 ([#1040](#1040)).
CLI: * Add documentation for positional args in commands generated from the Databricks OpenAPI specification ([#1033](#1033)). * Ask for host when .databrickscfg doesn't exist ([#1041](#1041)). * Add list of supported values for flags that represent an enum field ([#1036](#1036)). Bundles: * Fix panic when bundle auth resolution fails ([#1002](#1002)). * Add versioning for bundle templates ([#972](#972)). * Add support for conditional prompting in bundle init ([#971](#971)). * Pass parameters to task when run with `--python-params` and `python_wheel_wrapper` is true ([#1037](#1037)). * Change default_python template to auto-update version on each wheel build ([#1034](#1034)). Internal: * Rewrite the friendly log handler ([#1038](#1038)). * Move bundle schema update to an internal module ([#1012](#1012)). Dependency updates: * Bump github.com/databricks/databricks-sdk-go from 0.26.0 to 0.26.1 ([#1040](#1040)).
## Changes It wasn't working because it deferred to the regular `slog.TextHandler` for the `WithAttr` and `WithGroup` functions. Both of these functions don't mutate the handler but return a new one. When the top-level logger called one of these, log records in that context used the standard handler instead of ours. To implement tracking of attributes and groups, I followed the guide at https://github.com/golang/example/blob/master/slog-handler-guide/README.md for writing custom handlers. ## Tests The new tests demonstrate formatting through `t.Log` and look good.
CLI: * Add documentation for positional args in commands generated from the Databricks OpenAPI specification ([#1033](#1033)). * Ask for host when .databrickscfg doesn't exist ([#1041](#1041)). * Add list of supported values for flags that represent an enum field ([#1036](#1036)). Bundles: * Fix panic when bundle auth resolution fails ([#1002](#1002)). * Add versioning for bundle templates ([#972](#972)). * Add support for conditional prompting in bundle init ([#971](#971)). * Pass parameters to task when run with `--python-params` and `python_wheel_wrapper` is true ([#1037](#1037)). * Change default_python template to auto-update version on each wheel build ([#1034](#1034)). Internal: * Rewrite the friendly log handler ([#1038](#1038)). * Move bundle schema update to an internal module ([#1012](#1012)). Dependency updates: * Bump github.com/databricks/databricks-sdk-go from 0.26.0 to 0.26.1 ([#1040](#1040)).













Changes
It wasn't working because it deferred to the regular
slog.TextHandlerfor theWithAttrandWithGroupfunctions. Both of these functions don't mutate the handler but return a new one. When the top-level logger called one of these, log records in that context used the standard handler instead of ours.To implement tracking of attributes and groups, I followed the guide at https://github.com/golang/example/blob/master/slog-handler-guide/README.md for writing custom handlers.
Tests
The new tests demonstrate formatting through
t.Logand look good.