code: function logWrap(level) {
      return function log() {
        let context, message, args, trace, err;
  
        if (arguments[0] instanceof Error) {
          // log.<level>(err, ...)
          context = API.getContext();
          args = Array.prototype.slice.call(arguments, 1);
          if (!args.length) {
            // log.<level>(err)
            err = arguments[0];
            message = err.name + ': ' + err.message;
          } else {
            // log.<level>(err, "More %s", "things")
            // Use the err as context information
            err = arguments[0];
            message = arguments[1];
            args = Array.prototype.slice.call(args, 1);
          }
        } else if (arguments[0] == null || (typeof (arguments[0]) !== 'object' && arguments[0] !== null) ||
            Array.isArray(arguments[0])) {
          // log.<level>(msg, ...)
          context = API.getContext();
          message = arguments[0];
          args = Array.prototype.slice.call(arguments, 1);
        } else {
          // log.<level>(fields, msg, ...)
          context = merge(API.getContext(), arguments[0]);
          message = arguments[1];
          args = Array.prototype.slice.call(arguments, 2);
        }
  
        trace = API.format(level, context || {}, message, args, err);
        API.stream.write(trace + '\n');
      };
    }
docs: Internal private function that implements a decorator to all
  the level functions.
  
  @param {String} level one of
  ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL']