3.0.2 β€’ Published 4 months ago

missionlog v3.0.2

Weekly downloads
223
License
MIT
Repository
github
Last release
4 months ago

missionlog

NPM version Coverage Status

πŸš€ missionlog is a lightweight, structured logging package designed for performance, flexibility, and ease of use. It works as a drop-in replacement for console.log or ts-log, and offers both log level filtering, optional tag filtering, and customizable output handlingβ€”all in a tiny (~1KB) package.

βœ” Fully Typed (TypeScript) β€’ βœ” ESM & CJS Support β€’ βœ” Zero Dependencies β€’ βœ” 100% Coverage


✨ Why Use missionlog?

βœ… Drop-in Replacement for console.log & ts-log – Start using it instantly!
βœ… Seamless Upgrade to Tagged Logging – Reduce log clutter and focus on what's important.
βœ… Configurable Log Levels – Adjust visibility for log level and tags at runtime.
βœ… Customizable Output – Send logs anywhere: console, JSON, cloud services.
βœ… Blazing Fast Performance – O(1) log level lookups for minimal overhead.
βœ… TypeScript-First – Full type safety, no need for @types.
βœ… Works Everywhere – Browser, Node.js, Firebase, AWS Lambda etc.

πŸ“¦ Installing

npm i missionlog  

🎯 Focus on What Matters, When It Matters

missionlog can filter logs dynamically by level or tag to avoid clutter and help you focus on what's important.

πŸš€ Example

import { DEFAULT_TAG, log, LogLevel, LogLevelStr, tag } from "missionlog";
import chalk from "chalk";

// Tags aren't required., This works just like console
log.error("Alert! Evil twin detected!");

// Use the built-in **"Dummy"** logger and becomes a no-op
log.info(tag.Engineering, "Engaging warp drive! Destination: The Final Frontier.");

// Assign tags levels, (TRACE < DEBUG < INFO < WARN < ERROR < OFF)
log.init({ Engineering: LogLevel.INFO, Transporter: LogLevel.DEBUG });

// Log with a tag
log.info(tag.Engineering, "Warp Factor 9!");

// Override the built-in **Dummy** logger with a custom behavior
log.init({ Engineering: LogLevel.INFO }, createLogHandler());

// Engineering's level is INFO+ so this gets logged!
log.info(tag.Engineering, "Warp Factor 5.");

// Gets filtered since Engineering is INFO+
log.debug(tag.Engineering, "Warp Factor 9!");

// Update tag levels and override default (INFO)
log.init({
  Engineering: LogLevel.TRACE,
  [DEFAULT_TAG]: LogLevel.ERROR, // used for logs without a tag
  Transporter: LogLevel.DEBUG,
});

// Log an error
const error = new Error("Warp core breach!");
log.error(tag.Engineering, "🚨 Red Alert!", error.message);

// Show some color!
log.debug(tag.Transporter, "✨ Beam me up, Scotty!");

// Log objects properly
log.warn(tag.Transporter, "Transporter anomaly detected,", { evilTwin: true });

// Replace dummy logger with custom behavior
function createLogHandler() {
  const logConfig: Record<
    LogLevelStr,
    { color: (text: string) => string; method: (...args: unknown[]) => void }
  > = {
    ERROR: { color: chalk.red, method: console.error },
    WARN: { color: chalk.yellow, method: console.warn },
    INFO: { color: chalk.green, method: console.log },
    DEBUG: { color: chalk.magenta, method: console.log },
    TRACE: { color: chalk.cyan, method: console.log },
    OFF: { color: () => '', method: () => {} }, // No-op
  };

  return (level: LogLevelStr, tag: string, message: unknown, params: unknown[]) => {
    const { method, color } = logConfig[level];  
    const logLine = `[${color(level)}] ${tag ? tag + ' - ' : ''}${message}`;
    method(logLine, ...params);
  };
}

Example Image


πŸ“„ License

MIT License
Β© 2019-2025 Ray Martone


πŸš€ Install missionlog today and make logging clean, structured, and powerful!

2.0.3

4 months ago

2.0.2

4 months ago

2.0.1

4 months ago

2.0.0

4 months ago

3.0.2

4 months ago

3.0.1

4 months ago

3.0.0

4 months ago

1.8.9

6 months ago

1.8.8

2 years ago

1.8.6

2 years ago

1.8.4

3 years ago

1.7.8

3 years ago

1.7.7

3 years ago

1.8.2

3 years ago

1.8.1

3 years ago

1.8.3

3 years ago

1.7.6

3 years ago

1.7.5

3 years ago

1.7.4

3 years ago

1.6.10

4 years ago

1.7.1

3 years ago

1.6.9

4 years ago

1.6.7

4 years ago

1.6.6

5 years ago

1.6.5

5 years ago

1.6.2

5 years ago

1.6.0

5 years ago

1.5.12

6 years ago

1.5.10

6 years ago

1.5.7

6 years ago

1.5.6

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.4

6 years ago

1.3.3

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.60

6 years ago

1.1.57

6 years ago

1.1.56

6 years ago

1.1.55

6 years ago

1.1.54

6 years ago

1.1.53

6 years ago

1.1.52

6 years ago

1.1.51

6 years ago

1.1.49

6 years ago

1.1.48

6 years ago

1.1.47

6 years ago

1.1.46

6 years ago

1.1.45

6 years ago

1.1.44

6 years ago

1.1.43

6 years ago

1.1.42

6 years ago

1.1.41

6 years ago

1.1.39

6 years ago

1.1.38

6 years ago

1.1.36

6 years ago

1.1.35

6 years ago

1.1.33

6 years ago

1.1.32

6 years ago

1.1.31

6 years ago

1.1.30

6 years ago

1.1.25

6 years ago

1.1.24

6 years ago

1.1.23

6 years ago

1.1.22

6 years ago

1.1.21

6 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.18

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago