Skip to content

Instantly share code, notes, and snippets.

@ededejr
Created June 13, 2023 21:18
Show Gist options
  • Save ededejr/0f7c1d810295341f1bd42055b71194d2 to your computer and use it in GitHub Desktop.
Save ededejr/0f7c1d810295341f1bd42055b71194d2 to your computer and use it in GitHub Desktop.
simple debug function which logs its caller
const debug = (...messages: unknown[]) => {
  const { stack } = new Error("");
  const caller = stack?.split("\n")?.[2].trim().split(" ")[1];
  console.log(`[ededejr|${caller}]: `, ...messages);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment