Closer/functions/src/log.ts

18 lines
695 B
TypeScript

import * as logger from 'firebase-functions/logger'
/**
* Structured logging for all functions. Prefer this over `console.*`: the v2 logger attaches
* execution/trace context automatically and supports a structured metadata object as the last arg
* (e.g. `logger.warn('msg', { code, uid })`), which is searchable in Cloud Logging.
*/
export { logger }
/**
* FCM registration tokens are device secrets — never log them in full. Use this to reduce a token
* to a short, non-identifying suffix for correlation in logs.
*/
export function redactToken(token: string | null | undefined): string {
if (!token) return '(none)'
return token.length <= 6 ? '***' : `${token.slice(-6)}`
}