fix: only log warnings and errors in prod (#618)

This commit is contained in:
Brace Sproul 2025-07-30 17:21:27 -07:00 • committed by GitHub
parent 2da1aa95ee
commit ba0ab56f4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -81,14 +81,20 @@ export function createLogger(level: LogLevel, prefix: string) {
? `[${prefix}]`
: `${BOLD}${color}[${prefix}]${RESET}`;
// In production, only allow warn and error logs
const isProduction = process.env.NODE_ENV === "production";
return {
debug: (message: string, data?: any) => {
if (level === LogLevel.DEBUG) {
if (!isProduction && level === LogLevel.DEBUG) {
logWithOptionalIds(styledPrefix, message, data);
}
},
info: (message: string, data?: any) => {
if (level === LogLevel.INFO || level === LogLevel.DEBUG) {
if (
!isProduction &&
(level === LogLevel.INFO || level === LogLevel.DEBUG)
) {
logWithOptionalIds(styledPrefix, message, data);
}
},