Introduction

What is Devlog?

Devlog is a lightweight logging library that automatically detects and displays the file and line number where each log statement is called. This makes debugging faster by eliminating the need to manually add context to your log messages.

Why Devlog?

Traditional console logging requires you to manually add context about where the log is coming from. With devlog, this context is automatically captured and displayed, saving you time and making your logs more informative.

typescript
// Traditional approach
console.log("[UserService.ts:42] User created:", user);
// With devlog
log.info("User created", user);
// Output: [UserService.ts:42] User created { id: 1, name: "Alice" }
Devlog output example — colored log levels with automatic file and line context

Devlog output example — colored log levels with automatic file and line context

Key Features

  • Automatic detection of calling file and line number
  • Zero dependencies - lightweight and fast
  • Works in both Node.js and browser environments
  • Five log levels: info, warn, error, success, debug
  • Colored output for better readability
  • Environment-based configuration for production

Comparison with console.log

Featureconsole.logdevlog
File/line contextManualAutomatic
Colored outputLimitedFull support
Log levelsBasic5 levels
Environment controlManualBuilt-in
Data formattingBasicEnhanced