fergusstrange/embedded-postgres

Logger parametr does'twork correctly

Closed this issue · 4 comments

Hey... I figured out that when I do something like
.......
logger, _ := zap.NewProduction()
defer logger.Sync()
logger.Info("failed to fetch URL",
// Structured context as strongly typed Field values.
zap.String("url", url),
zap.Int("attempt", 3),
zap.Duration("backoff", time.Second),
)
....
w := &zapio.Writer{Log: logger}

......
database := embeddedpostgres.NewDatabase(embeddedpostgres.DefaultConfig().
Version(embeddedpostgres.V12).
Port(Port).
RuntimePath(runtimePath).
StartTimeout(CACHE_DB_STARTUP_DELLAY_SECONDS).
Database(DbName).
Password(DbUsername).
Username(DbPasswd).
Logger(w))

the new io.writer for the instance is used (I see a new zap formatting applied for all messages) but by the end of the database startup it hangs and I need to kill the app.

i tried the lorgus and standard go logger and all of them were hanging after the database started up. The reason to use this embedded Postgre database is to get all logging coming from one place otherwise we can easily run the postgres instance at the pod and make it "embedded" so I think logging not working correctly is the ISSUE.

Hey @divo77,

Thanks for raising this, it's a known limitation.

I've made a few changes in a PR #41 which you could try against your local implementation using the commit latest SHA as a version.

If all looks good we'll merge this and get it released.

Thanks

THANKS A LOT. Tested it today and it works fine.

just used a version v1.10.0 and the issue wasn't fixed. Can you move the fix to the official release ?

A little sluggish but finally cut this release after some manual testing.

Release found @ https://github.com/fergusstrange/embedded-postgres/releases/tag/v1.11.0

Thanks @divo77