-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tflog+tfsdklog: Added
WithAdditionalLocationOffset
function (#36)
Reference: #29 Allows implementations to fix the location offset of caller information when using helper functions. While typically expected for subsystem loggers, SDKs could also offer the configuration of the root provider logger as well. Since each `hclog.Logger` is mainly immutable once its created (except for level and creating named sub-loggers), the `hclog.LoggerOptions` are saved to the context as well, allowing `NewSubsystem` to appropriately have all the root logger options available to create new sub-loggers. Maybe this can be changed upstream in the future, although that would technically be a breaking change since the interface would need to be modified. This changeset also includes setting the name of the test root SDK/provider loggers, so that subsystem naming (and therefore the unit testing) matches real world usage.
- Loading branch information
Showing
19 changed files
with
603 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
tflog: Added `WithAdditionalLocationOffset` function, which allows implementations to adjust the location offset when using helper functions | ||
``` | ||
|
||
```release-note:enhancement | ||
tfsdklog: Added `WithAdditionalLocationOffset` function, which allows implementations to adjust the location offset when using helper functions | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package hclogutils | ||
|
||
import ( | ||
"github.com/hashicorp/go-hclog" | ||
) | ||
|
||
// LoggerOptionsCopy will safely copy LoggerOptions. Manually implemented | ||
// to save importing a dependency such as github.com/mitchellh/copystructure. | ||
func LoggerOptionsCopy(src *hclog.LoggerOptions) *hclog.LoggerOptions { | ||
if src == nil { | ||
return nil | ||
} | ||
|
||
return &hclog.LoggerOptions{ | ||
AdditionalLocationOffset: src.AdditionalLocationOffset, | ||
Color: src.Color, | ||
DisableTime: src.DisableTime, | ||
Exclude: src.Exclude, | ||
IncludeLocation: src.IncludeLocation, | ||
IndependentLevels: src.IndependentLevels, | ||
JSONFormat: src.JSONFormat, | ||
Level: src.Level, | ||
Mutex: src.Mutex, | ||
Name: src.Name, | ||
Output: src.Output, | ||
TimeFormat: src.TimeFormat, | ||
TimeFn: src.TimeFn, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.