Blog
debug-logger.ts in Flyde codebase.

debug-logger.ts in Flyde codebase.

In this article, we will review debug-logger.ts in Flyde codebase. We will look at:

  1. debugLogger function

  2. debug package

debugLogger function

You will find the following code at flyde/core/src/common/debug-logger.ts

import debug from "debug";

const BASE_NS = `flyde`;

const base = debug(BASE_NS);

import type { Debugger as _Debugger } from "debug";

export type DebugLogger = _Debugger;

export const debugLogger = (subNs: string): DebugLogger => {
  return base.extend(subNs);
};

debug is imported and is assigned to base . In the debugLogger function, base is extended with the parameter passed.

debug package

A tiny JavaScript debugging utility modelled after Node.js core’s debugging technique. Works in Node.js and web browsers.

Installation

 npm install debug

Usage

Check out the debug usage in the documentation

About me:

Hey, my name is Ramu Narasinga. I study codebase architecture in large open-source projects.

Email: ramu.narasinga@gmail.com

Want to learn from open-source? Solve challenges inspired by open-source projects.

References:

  1. https://github.com/flydelabs/flyde/blob/main/core/src/common/debug-logger.ts#L11

  2. https://www.npmjs.com/package/debug

  3. https://github.com/flydelabs/flyde/blob/main/core/src/execute/index.ts#L103