Logging code—whether in middleware or reusable helpers—should be predictable, non-intrusive, and easy to format or disable.
const result = await toSSG(app, fs)
if (result.success) {
console.log('Static site generation completed!')
} else {
console.log('Failed!', result.error?.message)
}
const getTime: () => number =
performance?.now?.bind(performance) ??
(console.warn('performance.now is not supported, using Date.now'), Date.now.bind(Date))
Be careful about what you log from user-controlled input. Full request paths/query strings can be arbitrarily large or crafted to pollute logs or degrade performance; consider truncating or limiting what gets logged rather than dumping raw, unbounded strings.
746b or 1.9kb) and color should be an explicit, opt-in formatting step rather than baked into the value itself.Following these practices keeps logs useful, prevents performance/security issues from unbounded or repeated output, and gives consumers control over how and what gets logged.