A minimal, console-only logging utility that behaves exactly like logs-gateway console logging, with optional fail-fast error throwing.
npm install micro-logsA minimal, console-only logging utility that behaves exactly like logs-gateway console logging, with optional fail-fast error throwing.
* Console-only: Zero support for files, transports, or complex routing.
* Environment-driven: Configuration via environment variables.
* Logs-gateway parity: Identical log-level semantics and behavior.
* Fail-fast: Error logs throw by default (configurable).
* Zero dependencies: Lightweight and predictable.
``bash`
npm install micro-logs
`typescript
import { Logger } from 'micro-logs';
const logger = new Logger({
packageName: 'my-service',
debugNamespace: 'api:v1' // Optional
});
logger.info('Server started');
logger.debug('Processing request'); // Suppressed by default
logger.error('Database connection failed'); // Throws by default
`
Logs are filtered based on a minimum threshold. Supported levels (ordered):
1. verbosedebug
2. info
3. (default)warn
4. error
5.
Configure via: {ENV_PREFIX}_LOG_LEVEL (e.g., LOG_LEVEL=debug).
Enable verbose and debug logs for specific namespaces without lowering the global level.
Configure via: DEBUG (e.g., DEBUG=api:*,auth).
By default, calling logger.error() will throw an Error.
Configure via: {ENV_PREFIX}_THROW_ERROR (values: true | false`).
ISC