mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
backport of commit b2870dd23f (#23780)
Co-authored-by: John-Michael Faircloth <fairclothjm@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a9c009b860
commit
ccc79081fc
@@ -75,7 +75,7 @@ func main() {
|
||||
And that's basically it! You would just need to change `myPlugin` to your actual
|
||||
plugin.
|
||||
|
||||
## Plugin backwards compatibility with Vault
|
||||
### Plugin backwards compatibility with Vault
|
||||
|
||||
Let's take a closer look at a snippet from the above main package.
|
||||
|
||||
@@ -113,6 +113,25 @@ instead implement the
|
||||
[`PluginVersioner`](https://github.com/hashicorp/vault/blob/sdk/v0.6.0/sdk/logical/logical.go#L150-L154)
|
||||
interface directly.
|
||||
|
||||
## Plugin logging
|
||||
|
||||
Auth and secrets plugins based on `framework.Backend` from the SDK can take
|
||||
advantage of the SDK's [default logger](https://github.com/hashicorp/vault/blob/fe55cbbf05586ec4c0cd9bdf865ec6f741a8933c/sdk/framework/backend.go#L437).
|
||||
No additional setup is required. The logger can be used like the following:
|
||||
|
||||
```go
|
||||
func (b *backend) example() {
|
||||
b.Logger().Trace("Trace level log")
|
||||
b.Logger().Debug("Debug level log")
|
||||
b.Logger().Info("Info level log")
|
||||
b.Logger().Warn("Warn level log")
|
||||
b.Logger().Error("Error level log")
|
||||
}
|
||||
```
|
||||
|
||||
See the source code of [vault-auth-plugin-example](https://github.com/hashicorp/vault-auth-plugin-example)
|
||||
for a more complete example of a plugin using logging.
|
||||
|
||||
## Building a plugin from source
|
||||
|
||||
To build a plugin from source, first navigate to the location holding the
|
||||
|
||||
Reference in New Issue
Block a user