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