chalk#Chalk TypeScript Examples

The following examples show how to use chalk#Chalk. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.d.ts    From amazon-kinesis-video-streams-webrtc-sdk-js-with-amazon-cognito with MIT No Attribution 6 votes vote down vote up
/**
 * Take TypeScript errors, parse them and format to webpack errors
 * Optionally adds a file name
 */
export declare function formatErrors(diagnostics: ReadonlyArray<typescript.Diagnostic> | undefined, loaderOptions: LoaderOptions, colors: Chalk, compiler: typeof typescript, merge: {
    file?: string;
    module?: WebpackModule;
}, context: string): WebpackError[];
Example #2
Source File: node-colors.ts    From xiome with MIT License 6 votes vote down vote up
export function nodeColors(force?: boolean): Colors {
	let chalkstick: ChalkInstance

	if (force === true)
		chalkstick = new Chalk({level: 1})
	else if (force === false)
		chalkstick = new Chalk({level: 0})
	else
		chalkstick = new Chalk()

	const bind = <T extends Colorizer>(colorfunc: T) =>
		colorfunc.bind(chalkstick)

	return {
		log: bind(chalkstick.cyan),
		info: bind(chalkstick.cyanBright),
		debug: bind(chalkstick.blueBright),
		warn: bind(chalkstick.yellow),
		error: bind(chalkstick.redBright),
	}
}
Example #3
Source File: config.d.ts    From amazon-kinesis-video-streams-webrtc-sdk-js-with-amazon-cognito with MIT No Attribution 5 votes vote down vote up
export declare function getConfigFile(compiler: typeof typescript, colors: Chalk, loader: webpack.loader.LoaderContext, loaderOptions: LoaderOptions, compilerCompatible: boolean, log: logger.Logger, compilerDetailsLogMessage: string): {
    configFilePath: string | undefined;
    configFile: ConfigFile;
    configFileError: WebpackError | undefined;
};
Example #4
Source File: logger.d.ts    From amazon-kinesis-video-streams-webrtc-sdk-js-with-amazon-cognito with MIT No Attribution 5 votes vote down vote up
export declare function makeLogger(loaderOptions: LoaderOptions, colors: Chalk): Logger;
Example #5
Source File: logger.ts    From subsocial-js with GNU General Public License v3.0 5 votes vote down vote up
colors: Record<Levels, Chalk> = {
  TRACE: chalk.magenta,
  DEBUG: chalk.cyan,
  INFO: chalk.blue,
  WARN: chalk.yellow,
  ERROR: chalk.red,
  SILENT: chalk.gray
}
Example #6
Source File: LogService.ts    From yana with MIT License 5 votes vote down vote up
private static createLogger(name: string, level: LogLevel = LogLevel.log) {
    LogService.colorCounter++;
    LogService.colorCounter = LogService.colorCounter % LogService.colors.length;
    const color = LogService.colors[LogService.colorCounter];

    const createLogHandler = (level: LogLevel): LogHandler => (description, appendedValues = [], subStructure) => {
      if (!LogService.enabled) return;
      if (LogService.whitelist.length && !LogService.whitelist.includes(name)) return;
      if (LogService.blacklist.length && LogService.blacklist.includes(name)) return;

      let handler: (...a: any[]) => void;
      let prefixColor: Chalk;
      let prefixValue: string;

      switch (level) {
        case LogLevel.debug:
          handler = console.debug;
          prefixColor = chalk.blueBright;
          prefixValue = 'DEBUG';
          break;
        case LogLevel.info:
          handler = console.info;
          prefixColor = chalk.blue;
          prefixValue = 'INFO';
          break;
        case LogLevel.log:
          handler = console.log;
          prefixColor = chalk.black;
          prefixValue = 'LOG';
          break;
        case LogLevel.warn:
          handler = console.warn;
          prefixColor = chalk.yellow;
          prefixValue = 'WARN';
          break;
        case LogLevel.error:
          handler = console.error;
          prefixColor = chalk.red;
          prefixValue = 'ERROR';
          break;
      }

      const css = [
        `color: ${color[1]}; background: ${color[0]}`,
        `color: #000; background: #fff`,
        `color: #444; background: #fff`,
      ];

      if (subStructure) {
        console.groupCollapsed(
          `%c[${name}]%c: ${description}. %c${appendedValues.map(v => JSON.stringify(v))}`,
          ...css
        );
      } else {
        handler(`%c[${name}]%c: ${description}. %c${appendedValues}`, ...css);
      }

      if (subStructure) {
        for (const [key, value] of Object.entries(subStructure)) {
          handler(`${key}:`, value);
        }
        console.groupEnd();
      }

      handler();
    };

    this.loggers.push({
      name,
      level,
      color,
      log: createLogHandler(LogLevel.log),
      debug: createLogHandler(LogLevel.debug),
      warn: createLogHandler(LogLevel.warn),
      error: createLogHandler(LogLevel.error),
      out: createLogHandler(level),
    });
    return this.loggers[this.loggers.length - 1];
  }