docs: function extendLogFunction(target, log) {
    /**
     * An extension of the conventional log method that first checks if the first argument contains a valid log level and
     * if so instead delegates the call to the appropriate logging function for the specified log level (passing the rest
     * of the first argument (if any) and all arguments after the first argument to it); or otherwise simply delegates the
     * log call to the underlying logger's log method passing ALL of the original arguments to it.
     * @param {...*} data - zero or more data items to be logged - with special meaning assigned to the first argument by
     * this function and also possibly by the underlying logger's log method (e.g. see console.log)
     */
    function logAtLevel(data) {
      const self = this || target;
      // If NO arguments were passed, then delegate a no-arg call to the given logger log function
      const len = arguments.length;
      if (len <= 0) {
        log();
        return;
      }
      const [logLevel, rest] = extractLogLevelAndRest(arguments[0]);
  
      let args;
      if (!logLevel) {
        // No log level, so use all arguments passed as is
        args = arguments;
      } else if (rest) {
        // First argument contained MORE than just a log level, so use the rest of the first argument as the first argument
        args = arguments;
        args[0] = rest;
      } else {
        // First argument ONLY contained a log level, so drop the first argument
        args = new Array(len - 1);
        for (let i = 1; i < len; ++i) {
          args[i - 1] = arguments[i];
        }
      }
  
      switch (logLevel) {
        case LogLevel.ERROR:
          self.error.apply(null, args);
          return;
  
        case LogLevel.WARN:
          self.warn.apply(null, args);
          return;
  
        case LogLevel.INFO:
          self.info.apply(null, args);
          return;
  
        case LogLevel.DEBUG:
          self.debug.apply(null, args);
          return;
  
        case LogLevel.TRACE:
          self.trace.apply(null, args);
          return;
  
        case 'LOG':
          log.apply(null, args); // log is already bound to its logger, so ignore thisArg
          return;
  
        default:
          // If no valid log level was provided as a first argument then default to calling the given logger log function
          // using ALL of the arguments as data
          log.apply(null, arguments); // log is already bound to its logger, so ignore thisArg
          return;
      }
    }
  
    return logAtLevel;
  }