fauna / fauna-js

Javascript driver for Fauna v10 (current)
https://fauna.com
Other
37 stars 7 forks source link

util/logging.ts: Add support for logging #308

Open findgriffin opened 1 week ago

findgriffin commented 1 week ago

util/logging.ts: Add LogHandler interface, LogLevel enum, and ConsoleLogHandler.

Description

Add a log handler interface and implementation.

Motivation and context

Following a LSE where we couldn't get reliable information from the customer side, we decided to add a logging facility to all of the drivers.

I spent a few hours surveying log library options in JavaScript/TypeScript. The conclusion that I came to is that they are either bulkier than what we need (log4js-node) or so simple that it's not worth us taking a dependency (pino), hence the strategy I adopted in this PR.

TODO: This PR does not yet actually call our log function from the request/response path, I thought the tests were failing on Monday. They appear to pass in GitHub Actions, so maybe that's a "fails on my machine" type of thing.

How was the change tested?

Unit tests?

Screenshots (if appropriate):

Change types

Checklist:


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ptpaterson commented 6 days ago

We should put together some tests that demonstrate using logger stuff. But I've updated the things I have opinions and commented about.