'use strict';

var winston = require('winston');
var stream = require('stream');
var process$1 = require('process');

function _interopNamespaceCompat(e) {
  if (e && typeof e === 'object' && 'default' in e) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var winston__namespace = /*#__PURE__*/_interopNamespaceCompat(winston);

const convertTechDocsRefToLocationAnnotation = (techdocsRef) => {
  const [type, target] = techdocsRef.split(/:(.+)/);
  if (!type || !target) {
    throw new Error(
      `Can not parse --techdocs-ref ${techdocsRef}. Should be of type HOST:URL.`
    );
  }
  return { type, target };
};
const createLogger = ({
  verbose = false
}) => {
  const logger = winston__namespace.createLogger({
    level: verbose ? "verbose" : "info",
    transports: [
      new winston__namespace.transports.Console({ format: winston__namespace.format.simple() })
    ]
  });
  return logger;
};
const getLogStream = (logger) => {
  if (process.env.LOG_LEVEL === "debug") {
    return process$1.stdout;
  }
  return new stream.Writable({
    defaultEncoding: "utf8",
    write(chunk, _encoding, next) {
      logger.verbose(chunk.toString().trim());
      next();
    }
  });
};

exports.convertTechDocsRefToLocationAnnotation = convertTechDocsRefToLocationAnnotation;
exports.createLogger = createLogger;
exports.getLogStream = getLogStream;
//# sourceMappingURL=utility-CsspJYjU.cjs.js.map
