Python logging module (Singleton)

import logging
logger = logging.getLogger(__name__)

The logging module already implements a singleton pattern for you - when you call logger.getLogger(name), it will create the logger if it hasn't done so already and return it.

This is concise, while allowing downstream code fine-grained control if needed. Logged messages to the module-level logger get forwarded to handlers of loggers in higher-level modules, all the way up to the highest-level logger known as the root logger; this approach is known as hierarchical logging.

Loggers should NEVER be instantiated directly, but always through the module-level function logging.getLogger(name). Multiple calls to getLogger() with the same name will always return a reference to the same Logger object.

logging.getLogger(name=None)

Return a logger with the specified name or, if name is None, return a logger which is the root logger of the hierarchy. If specified, the name is typically a dot-separated hierarchical name like ‘a’‘a.b’ or ‘a.b.c.d’. Choice of these names is entirely up to the developer who is using logging. All calls to this function with a given name return the same logger instance. This means that logger instances never need to be passed between different parts of an application.

https://github.com/python/cpython/blob/3.12/Lib/logging/__init__.py

logging — Logging facility for Python

Express.js (Facade)

var express = require('express');
var router = express.Router();

The routing mechanism in Express.js. Express provides an easy-to-use interface to define routes for various HTTP methods. Instead of interacting with the raw HTTP objects, developers use Express methods like app.get(), app.post(), etc., to define endpoints and their corresponding handlers. This approach hides the complexity of matching URL patterns and invoking appropriate handlers.

Primarily implemented in the lib/router directory, specifically within index.js and route.js. These files provide the functionality that allows developers to define routes using methods like app.get(), app.post(), and others.

proto.route = function route(path) {
  var route = new Route(path);

  this.stack.push(route);
  return route;
};

methods.forEach(function(method){
  proto[method] = function(path) {
    var route = this.route(path);
    route[method].apply(route, slice.call(arguments, 1));
    return this;
  };
});