@hyperfrontend/project-scope/core/loggerlogger
Scoped logger built on @hyperfrontend/logging with namespace prefixes, automatic secret sanitization, and a global log level registry.
createScopedLogger(namespace, options?) returns a frozen logger whose output is prefixed with [namespace] and whose metadata objects are recursively scrubbed for sensitive keys (matching patterns like 'token', 'key', 'password', 'secret', 'credential', 'auth', 'bearer', 'api_key', 'private', 'passphrase'). All loggers register themselves so setGlobalLogLevel can flip verbosity across the entire library at once. A default logger instance scoped to project-scope is exported for general use.
API Reference§
ƒ Functions
Parameters
| Name | Type | Description |
|---|---|---|
§namespace | string | Logger namespace (e.g., 'project-scope', 'analyze') |
§options | ScopedLoggerOptions | Logger configuration options(default: {}) |
Returns
ScopedLoggerExample
Creating a scoped logger
const logger = createScopedLogger('project-scope')
logger.setLogLevel('debug')
// Basic logging
logger.info('Starting analysis', { path: './project' })
// Sensitive data is automatically redacted
logger.debug('Config loaded', { apiKey: 'secret123' })
// Output: [project-scope] Config loaded {"apiKey":"[REDACTED]"}Returns
LogLevelExample
Getting current log level
setGlobalLogLevel('debug')
const level = getGlobalLogLevel()
// => 'debug'Example
Resetting the global log level
setGlobalLogLevel('debug')
// ... perform debugging ...
resetGlobalLogLevel()
// Global override removed, loggers use individual levelsParameters
| Name | Type | Description |
|---|---|---|
§obj | unknown | Object to sanitize |
Returns
unknownExample
Sanitizing sensitive data
const config = { apiKey: 'secret123', endpoint: 'https://api.example.com' }
const safe = sanitize(config)
// => { apiKey: '[REDACTED]', endpoint: 'https://api.example.com' }Example
Enabling debug logging globally
import { setGlobalLogLevel } from '@hyperfrontend/project-scope/core'
// Enable debug logging for all project-scope modules
setGlobalLogLevel('debug')◈ Interfaces
Properties
Properties
◆ Types
type LogLevel = "none" | "error" | "warn" | "log" | "info" | "debug"