@drainpixie/pika
Version:
a cute and shiny logger
143 lines (139 loc) • 3.75 kB
text/typescript
import { WriteStream } from 'node:tty';
/**
* The available figures.
*/
declare const Figure: {
readonly TICK: "✓";
readonly INFO: "i";
readonly CROSS: "×";
readonly WARNING: "!";
readonly ELLIPSIS: "…";
readonly POINTER_SMALL: "›";
};
/**
* The available figures.
*/
type Figure = (typeof Figure)[keyof typeof Figure];
/**
* The available colours.
*/
declare const Colour: {
readonly RED: "\u001B[31m";
readonly BOLD: "\u001B[1m";
readonly GREY: "\u001B[0;37m";
readonly BLUE: "\u001B[34m";
readonly CYAN: "\u001B[36m";
readonly RESET: "\u001B[0m";
readonly GREEN: "\u001B[32m";
readonly YELLOW: "\u001B[33m";
readonly MAGENTA: "\u001B[35m";
readonly UNDERLINE: "\u001B[4m";
};
/**
* The available colours.
*/
type Colour = (typeof Colour)[keyof typeof Colour];
/**
* The available levels.
*/
declare const Level: {
readonly TRACE: 0;
readonly DEBUG: 1;
readonly INFO: 2;
readonly WARN: 3;
readonly ERROR: 4;
readonly FATAL: 5;
};
/**
* The available levels.
*/
type Level = (typeof Level)[keyof typeof Level];
type LogTypeName = "success" | "warn" | "error" | "fatal" | "trace" | "debug" | "info";
interface LogType {
readonly label: string;
readonly level: Level;
readonly badge: Figure | string;
readonly colour: Colour;
readonly stream: WriteStream | NodeJS.WriteStream;
}
declare const colour: (input: string, ...colours: readonly Colour[]) => string;
declare function shouldUseColors(): boolean;
/**
* The options for a Pika instance.
*/
interface PikaOptions {
/**
* The scope of the logger.
*/
readonly scope: string;
/**
* The level of the logger.
*/
readonly level: Level;
/**
* The secrets to filter.
*/
readonly secrets: readonly string[];
/**
* Whether to use colors.
*/
readonly useColors: boolean;
}
/**
* A Pika logger.
*/
type PikaLogMethod = (...args: readonly unknown[]) => void;
/**
* A Pika logger.
*/
declare class Pika {
#private;
/**
* Creates a new instance of Pika.
* @param options The options for the instance.
*/
constructor(options?: Partial<PikaOptions>);
/**
* Clones the current instance with the given scope.
* @param scope The scope to set.
* @returns A new instance with the given scope.
*/
scope(scope: string): Pika;
/**
* Clones the current instance with the given level.
* @param level The level to set.
* @returns A new instance with the given level.
*/
level(level: Level): Pika;
/**
* Clones the current instance with the given secrets.
* @param secrets The secrets to add.
* @returns A new instance with the given secrets.
*/
secrets(...secrets: readonly string[]): Pika;
/**
* Returns the current options.
* @returns The current options.
*/
get options(): Partial<PikaOptions>;
/**
* Clones the current instance with the given options.
* @param overrides The options to override.
* @returns A new instance with the given options.
*/
clone(overrides?: Partial<PikaOptions>): Pika;
readonly success: PikaLogMethod;
readonly error: PikaLogMethod;
readonly fatal: PikaLogMethod;
readonly trace: PikaLogMethod;
readonly debug: PikaLogMethod;
readonly warn: PikaLogMethod;
readonly info: PikaLogMethod;
}
/**
* Creates a new instance of Pika.
* @param options The options for the instance.
* @returns A new instance of Pika.
*/
declare const pika: (options?: Partial<PikaOptions>) => Pika;
export { Colour, Figure, Level, type LogType, type LogTypeName, Pika, type PikaOptions, colour, pika, shouldUseColors };