Logging

Use the log helper from @tinycld/core/lib/logger instead of console.log. The four levels map to familiar semantics, and log.error automatically forwards to Sentry so you don’t have to remember a second call.

The pattern

import { log } from '@tinycld/core/lib/logger'

export function useImport() {
    const start = (filename: string) => {
        log.info('Import started', { filename })
    }

    const finish = (filename: string, count: number) => {
        log.debug('Import batch complete', { filename, count })
    }

    const warnSlow = (ms: number) => {
        log.warn('Import took longer than expected', { ms })
    }

    const fail = (filename: string, err: unknown) => {
        log.error('Import failed', { filename, err })
    }

    return { start, finish, warnSlow, fail }
}

The logger shows timestamps and colors in development and quiets down in production. Structured context (the second argument) is preferred over string interpolation - it survives serialization and makes future log-level search easier.

Levels

Caught exceptions

For caught exceptions that you want reported without adding a log line, use captureException from @tinycld/core/lib/errors:

import { captureException } from '@tinycld/core/lib/errors'

try {
    await pb.collection('example').create(data)
} catch (err) {
    captureException(err, { extra: { data } })
    throw err
}

captureException reports to Sentry with the extra context attached. Rethrow if the caller should still see the failure; swallow only if the error is genuinely non-fatal for the surface you’re on.

Don’t use console

console.log is suppressed in production builds anyway and bypasses Sentry entirely. The biome config lints direct console.* usage in package code - migrate to log and the warnings go away.