question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: 3.0 API & Ideas

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:95 (61 by maintainers)

github_iconTop GitHub Comments

12reactions
yamikuronuecommented, Dec 14, 2016

I think the most important thing to keep in mind is simplicity. This module is incredibly simple to use; you’ll want to make sure it remains dead simple to use, and is as simple as possible to extend and configure.

11reactions
adoyle-hcommented, Jan 5, 2017

I think it will be a great feature to achieve the “Ability to enable/disable specific debugging namespaces at runtime”. Sometimes I want to debug a http server step by step. For examples,

debug.enable('connect:*');
// check out the logs
debug.disable('connect:*');
debug.enable('http:body-parser');
// send request and check out the logs
debug.disable('http:body-parser');
debug.enable('http:response');
// send another request and check out the logs
// ...

Changing environment variables could also work. Stopping the server, setting different environment variables, restarting server again, and it maybe cost much time for waiting server to start. So it is complicated for the scenario. I desire to debug without shutting down the process.

middleware is a way to transform data in a pipeline. But how to extend the debug instance itself? To implement debug.enable(namespace) and debug.disable(namespace) methods. Could you provide any appropriate cases? @thebigredgeek

Read more comments on GitHub >

github_iconTop Results From Across the Web

REST API Media Types draft-ietf-httpapi-rest-api-mediatypes-02
Replaces, draft-polli-rest-api-mediatypes. RFC stream, Internet Engineering Task Force (IETF). Intended RFC status, (None). Formats.
Read more >
Vue 3.0 Discards Class-Based API for Reusable, Composable ...
The Vue team recently opened an RFC which describes the proposed function-based component API for the upcoming Vue 3.
Read more >
OpenAPI Specification - Version 3.0.3 - Swagger
The OpenAPI Specification defines a standard interface to RESTful APIs which allows both humans and computers to understand service capabilities without ...
Read more >
OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >
[RFC]: Bareflank 3.0 · Issue #884 - GitHub
Port Bareflank to the BSL with the existing APIs. Implement SOLID and Static Interfaces; Add AMD support; Implement all unit tests; Implement ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found