Dasasian ← The work

firebase-structured-logger

structured logging for both halves of a Firebase app, in one pane

@dasasian/firebase-structured-logger: structured logging for Firebase apps. A minified stack frame resolved back to its source file and line.

fsl.dasasian.com →

MIT · open source · on npm and GitHub

What it is

A logging library for apps on Firebase and Google Cloud. The backend writes structured entries. The browser sends its errors, its warnings and what a user reports, and each error arrives with its stack resolved to the file and line we wrote. Both halves go to one stream, in the Google Cloud project the app already runs in, so one filter reads the whole story.

It has its own site, with the docs and the reasons to use it.

Why we made it

We build our apps on Firebase, and we could not read the errors from our own frontends. They arrived as a position in a minified bundle, or they did not arrive at all, and we could not tell which. So we fixed it in one place and kept adding to it.

Most of what is in it now came from something going wrong: labels that looked right and could not be filtered, one request’s user on the next request’s logs, source maps published next to the app. Each one took us an afternoon to find, and then it became a test. The product site lists eight of them.

The rule it is built on

Logging is an aspect of an app, not a part of each function. A function should read the same with logging or without it.

So we moved that work out of the business code. The user is set once, where they sign in. A dialog is named by one attribute on the dialog. A handler is wrapped once, and every entry it writes has its name and its caller on it. No function takes a logger as an argument.

It is the same question we ask on everything we make: who absorbs the awkwardness. Here the person using it is a developer, and the awkwardness is log code in every function. We put that in the library.

How we check it

The package keeps a list of the ways it has broken, and each one has a test that fails if it comes back.

We check the docs the same way. Before the product site went up, we compiled every code example on it against the released package, and we ran each instruction against the released tool. Four examples did not work as written. We fixed them, and we check the pages again at each release.

Where it stops

It has no dashboard. Google Cloud already runs an error tracker in your project, and it groups errors well once the stacks can be read. We make the stacks readable and stop there. Assignment, ownership and a support line are a hosted tracker’s job, and this does not do them.

Specifics

Package
@dasasian/firebase-structured-logger on npm. Source on GitHub.
Docs
fsl.dasasian.com
Runs on
The browser, and Cloud Functions, Cloud Run or any Node server on Google Cloud.
Pairs with
firebase-mcp-server, when the agent reading the logs also needs the Firestore data they point at.
License
MIT

More open source

gdocs-mcp
A Google Doc as a local file, for an agent.
firebase-mcp-server
A schema-aware view of Firebase, for an agent.