3.0.2 β€’ Published 11 months ago

missionlog v3.0.2

Weekly downloads
223
License
MIT
Repository
github
Last release
11 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

11 months ago

2.0.2

11 months ago

2.0.1

11 months ago

2.0.0

11 months ago

3.0.2

11 months ago

3.0.1

11 months ago

3.0.0

11 months ago

1.8.9

1 year ago

1.8.8

3 years ago

1.8.6

3 years ago

1.8.4

3 years ago

1.7.8

4 years ago

1.7.7

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.8.3

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.6.10

4 years ago

1.7.1

4 years ago

1.6.9

4 years ago

1.6.7

5 years ago

1.6.6

5 years ago

1.6.5

6 years ago

1.6.2

6 years ago

1.6.0

6 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

7 years ago

1.1.60

7 years ago

1.1.57

7 years ago

1.1.56

7 years ago

1.1.55

7 years ago

1.1.54

7 years ago

1.1.53

7 years ago

1.1.52

7 years ago

1.1.51

7 years ago

1.1.49

7 years ago

1.1.48

7 years ago

1.1.47

7 years ago

1.1.46

7 years ago

1.1.45

7 years ago

1.1.44

7 years ago

1.1.43

7 years ago

1.1.42

7 years ago

1.1.41

7 years ago

1.1.39

7 years ago

1.1.38

7 years ago

1.1.36

7 years ago

1.1.35

7 years ago

1.1.33

7 years ago

1.1.32

7 years ago

1.1.31

7 years ago

1.1.30

7 years ago

1.1.25

7 years ago

1.1.24

7 years ago

1.1.23

7 years ago

1.1.22

7 years ago

1.1.21

7 years ago

1.1.20

7 years ago

1.1.19

7 years ago

1.1.18

7 years ago

1.1.17

7 years ago

1.1.16

7 years ago

1.1.15

7 years ago

1.1.14

7 years ago

1.1.13

7 years ago

1.1.12

7 years ago

1.1.11

7 years ago

1.1.10

7 years ago

1.1.9

7 years ago

1.1.8

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago