Skip to main content
Version: 1.9.0

Request logging

Overview​

Legacy API logs are one line per event, with scalar key=value fields, so Clever log search can filter by area (documents, files, HTTP) without dumping request bodies or Mongoose documents.

How it works​

app/middleware/logger.js derives [service] from the caller file path and prints [I], [W], or [E].

  • HTTP middleware logs request at info.
  • Document ingest logs saved file and created document. bcyip_agent and version come from Bcyip-Agent and Bcyip-Version and are omitted when blank.
  • Credits and Mongo connect log at info. Client 4xx logs at warn. Zip, download, and Mongo failures log at error.
  • saved-file-log.js emits saved file without requiring files.js from documents.linkFile, which previously broke the documents/files circular load and left logSavedFile undefined.
  • pipeStreamToResponse handles pkgcloud, archiver, and busboy stream errors without sending a second HTTP 500.

Key files​

  • app/middleware/logger.js — Line format and request middleware
  • app/middleware/logger-core.js — Scalar field formatting
  • app/services/saved-file-log.js — Ingest saved file lines
  • app/util/http-stream.js — Stream error guard

Technical decisions​

  • Scalar fields only. Objects, documents, and raw errors are not passed to the logger.
  • The service name comes from the caller path so routes do not pass a label on every call.