Skip to content

RFC: 3.0 API & Ideas #370

Closed
Closed
@thebigredgeek

Description

@thebigredgeek

Hey everyone,

I figured it's time to start discussing the API for V3.

A few fundamental ideas to get started:

  • (No) Code written in ES2015 (minimal transpilation?, no es6 modules)
  • (Yes) Robust test coverage
  • (Yes) XO Code Styling
  • (Yes) "Replaceable middleware" pattern for formatting, output, etc. Extensible. This allows hooks for stuff like logstash and client-to-server log streaming as desired. Middleware is FIFO and debug comes with a default set for formatting, output, environment adaptation, etc. Ex:
 //Stdout would be default console.log middleware
import debug, { StdoutMiddleware } from 'debug';
// Add some sort of new middleware element
log.use((data, next) => ... )
// replace Stdout (console.log) with console.info at same position in middleware array
log.replace(StdoutMiddleware, (data, next) => {
  console.info.apply(console, data);
  next(); 
});
  • (Yes) "Child" debug instances (which inherit middleware from parent debug instances). Ex:
const log1 = debug('foo');
log1.use((data, next) => ... );
const log2 = log.child('bar');
log2('hello world'); // => foo:bar hello world

Any other ideas are welcome. I'd love to have a completed first pass draft by the end of next week.

Metadata

Metadata

Labels

discussionThis issue is requesting comments and discussion

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions