milpa logger

This commit is contained in:
Roberto Hidalgo 2023-04-28 18:49:59 -06:00
parent cf0988c616
commit e078472c1c
2 changed files with 15 additions and 13 deletions

View File

@ -175,7 +175,7 @@ export PLUGIN_SHA="$(openssl dgst -sha256 -hex "$VAULT_PLUGIN_DIR/joao" | awk '{
export VERSION="$($VAULT_PLUGIN_DIR/joao --version)" export VERSION="$($VAULT_PLUGIN_DIR/joao --version)"
# register # register
vault plugin register -sha256="$PLUGIN_SHA" -command=joao -args="vault,server" -version="$VERSION" secret joao vault plugin register -sha256="$PLUGIN_SHA" -command=joao -args="vault-plugin" -version="$VERSION" secret joao
# configure, add `vault` to set a default vault for querying # configure, add `vault` to set a default vault for querying
vault write config/1password "host=$OP_CONNECT_HOST" "token=$OP_CONNECT_TOKEN" # vault=my-default-vault vault write config/1password "host=$OP_CONNECT_HOST" "token=$OP_CONNECT_TOKEN" # vault=my-default-vault

26
main.go
View File

@ -6,24 +6,26 @@ import (
"os" "os"
"git.rob.mx/nidito/chinampa" "git.rob.mx/nidito/chinampa"
"git.rob.mx/nidito/chinampa/pkg/env"
"git.rob.mx/nidito/chinampa/pkg/logger"
"git.rob.mx/nidito/chinampa/pkg/runtime" "git.rob.mx/nidito/chinampa/pkg/runtime"
"git.rob.mx/nidito/joao/cmd" "git.rob.mx/nidito/joao/cmd"
"git.rob.mx/nidito/joao/pkg/version" "git.rob.mx/nidito/joao/pkg/version"
"github.com/sirupsen/logrus"
) )
func main() { func logLevel() logger.Level {
logrus.SetFormatter(&logrus.TextFormatter{ if os.Getenv(env.Debug) == "trace" {
DisableLevelTruncation: true, return logger.LevelTrace
DisableTimestamp: true, } else if runtime.DebugEnabled() {
ForceColors: runtime.ColorEnabled(), return logger.LevelDebug
})
if runtime.DebugEnabled() {
logrus.SetLevel(logrus.DebugLevel)
logrus.Debug("Debugging enabled")
} }
return logger.LevelInfo
}
func main() {
logger.Configure("joao", logLevel())
chinampa.Register( chinampa.Register(
cmd.Get, cmd.Get,
cmd.Set, cmd.Set,
@ -48,7 +50,7 @@ Secret values are specified using the ﹅!!secret﹅ YAML tag.
`, `,
Version: version.Version, Version: version.Version,
}); err != nil { }); err != nil {
logrus.Errorf("total failure: %s", err) logger.Errorf("total failure: %s", err)
os.Exit(2) os.Exit(2)
} }
} }