@augment-vir/common
Version:
A collection of augments, helpers types, functions, and classes for any JavaScript environment.
57 lines (56 loc) • 1.68 kB
TypeScript
import { type PartialWithUndefined } from '@augment-vir/core';
import { type LoggerOptions } from './log-string.js';
import { type LogWriters } from './log-writer.js';
import { type Logger } from './logger.js';
/**
* Default implementation of {@link LogWriters} that is dependent on the current runtime environment.
*
* @category Log : Util
* @category Package : @augment-vir/common
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export declare const defaultLogWriters: LogWriters;
/**
* The default `log`. Use this in place of `console` methods for styled outputs in both Node.js and
* the browser.
*
* @category Log
* @category Package : @augment-vir/common
* @example
*
* ```ts
* import {log} from '@augment-vir/common';
*
* log.info('hi');
* log.error('failure');
* ```
*
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export declare const log: Logger;
/**
* Creates a custom logger that doesn't actually log but stores the logs into a object for later
* usage. This is particularly useful in tests.
*
* @category Log
* @category Package : @augment-vir/common
* @example
*
* ```ts
* import {createArrayLogger} from '@augment-vir/common';
*
* const {log, logs} = createArrayLogger();
*
* log.info('hi');
* // `logs[LogOutputType.Standard]` is now `['hi']`
* ```
*
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export declare function createArrayLogger(options?: PartialWithUndefined<LoggerOptions> | undefined): {
log: Logger;
logs: {
stdout: string[];
stderr: string[];
};
};