"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.disableLogging = disableLogging;
exports.log = log;
exports.logAnnotate = logAnnotate;
exports.logAnnotations = logAnnotations;
exports.logDebug = logDebug;
exports.logDebugCause = logDebugCause;
exports.logDebugCauseMessage = logDebugCauseMessage;
exports.logError = logError;
exports.logErrorCause = logErrorCause;
exports.logErrorCauseMessage = logErrorCauseMessage;
exports.logFatal = logFatal;
exports.logFatalCause = logFatalCause;
exports.logFatalCauseMessage = logFatalCauseMessage;
exports.logInfo = logInfo;
exports.logInfoCause = logInfoCause;
exports.logInfoCauseMessage = logInfoCauseMessage;
exports.logSpan = logSpan;
exports.logTrace = logTrace;
exports.logTraceCause = logTraceCause;
exports.logTraceCauseMessage = logTraceCauseMessage;
exports.logWarning = logWarning;
exports.logWarningCause = logWarningCause;
exports.logWarningCauseMessage = logWarningCauseMessage;

var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/LogLevel/definition"));

var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/data/Maybe/definition"));

var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Cause/definition"));

var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/LogSpan/definition"));

var tsplus_module_5 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/List/prepend"));

var tsplus_module_6 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/FiberRef/operations/currentLogSpan"));

var tsplus_module_7 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/FiberRef/operations/locally"));

var tsplus_module_8 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/suspendSucceed"));

var tsplus_module_9 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/FiberRef/operations/get"));

var tsplus_module_10 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/flatMap"));

var tsplus_module_11 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/ImmutableMap/set"));

var tsplus_module_12 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/FiberRef/operations/currentLogAnnotations"));

var tsplus_module_13 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@tsplus/stdlib/collections/HashSet/empty"));

var tsplus_module_14 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/RuntimeConfig/operations/make"));

var tsplus_module_15 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/withRuntimeConfig"));

var tsplus_module_16 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/runtimeConfig"));

var _primitives = /*#__PURE__*/require("@effect/core/io/Effect/definition/primitives");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

const fileName_1 = "(@effect/core) _src/io/Effect/operations/logging.ts";
const someFatal = /*#__PURE__*/tsplus_module_2.some(tsplus_module_1.Fatal);
const someError = /*#__PURE__*/tsplus_module_2.some(tsplus_module_1.Error);
const someWarning = /*#__PURE__*/tsplus_module_2.some(tsplus_module_1.Warning);
const someTrace = /*#__PURE__*/tsplus_module_2.some(tsplus_module_1.Trace);
const someInfo = /*#__PURE__*/tsplus_module_2.some(tsplus_module_1.Info);
const someDebug = /*#__PURE__*/tsplus_module_2.some(tsplus_module_1.Debug);
/**
 * Logs the specified message at the current log level.
 *
 * @tsplus static ets/Effect/Ops log
 */

function log(message, __tsplusTrace) {
  return new _primitives.ILogged(message, () => tsplus_module_3.empty, tsplus_module_2.none, null, null, __tsplusTrace);
}
/**
 * Logs the specified message at the debug log level.
 *
 * @tsplus static ets/Effect/Ops logDebug
 */


function logDebug(message, __tsplusTrace) {
  return new _primitives.ILogged(message, () => tsplus_module_3.empty, someDebug, null, null, __tsplusTrace);
}
/**
 * Logs the specified cause at the debug log level.
 *
 * @tsplus static ets/Effect/Ops logDebugCause
 */


function logDebugCause(cause, __tsplusTrace) {
  return new _primitives.ILogged(() => "", cause, someDebug, null, null, __tsplusTrace);
}
/**
 * Logs the specified message and cause at the debug log level.
 *
 * @tsplus static ets/Effect/Ops logDebugCauseMessage
 */


function logDebugCauseMessage(message, cause, __tsplusTrace) {
  return new _primitives.ILogged(message, cause, someDebug, null, null, __tsplusTrace);
}
/**
 * Logs the specified message at the error log level.
 *
 * @tsplus static ets/Effect/Ops logError
 */


function logError(message, __tsplusTrace) {
  return new _primitives.ILogged(message, () => tsplus_module_3.empty, someError, null, null, __tsplusTrace);
}
/**
 * Logs the specified cause at the error log level.
 *
 * @tsplus static ets/Effect/Ops logErrorCause
 */


function logErrorCause(cause, __tsplusTrace) {
  return new _primitives.ILogged(() => "", cause, someError, null, null, __tsplusTrace);
}
/**
 * Logs the specified message and cause at the error log level.
 *
 * @tsplus static ets/Effect/Ops logErrorCauseMessage
 */


function logErrorCauseMessage(message, cause, __tsplusTrace) {
  return new _primitives.ILogged(message, cause, someError, null, null, __tsplusTrace);
}
/**
 * Logs the specified message at the fatal log level.
 *
 * @tsplus static ets/Effect/Ops logFatal
 */


function logFatal(message, __tsplusTrace) {
  return new _primitives.ILogged(message, () => tsplus_module_3.empty, someFatal, null, null, __tsplusTrace);
}
/**
 * Logs the specified cause at the fatal log level.
 *
 * @tsplus static ets/Effect/Ops logFatalCause
 */


function logFatalCause(cause, __tsplusTrace) {
  return new _primitives.ILogged(() => "", cause, someFatal, null, null, __tsplusTrace);
}
/**
 * Logs the specified message and cause at the fatal log level.
 *
 * @tsplus static ets/Effect/Ops logFatalCauseMessage
 */


function logFatalCauseMessage(message, cause, __tsplusTrace) {
  return new _primitives.ILogged(message, cause, someFatal, null, null, __tsplusTrace);
}
/**
 * Logs the specified message at the informational log level.
 *
 * @tsplus static ets/Effect/Ops logInfo
 */


function logInfo(message, __tsplusTrace) {
  return new _primitives.ILogged(message, () => tsplus_module_3.empty, someInfo, null, null, __tsplusTrace);
}
/**
 * Logs the specified cause at the informational log level.
 *
 * @tsplus static ets/Effect/Ops logInfoCause
 */


function logInfoCause(cause, __tsplusTrace) {
  return new _primitives.ILogged(() => "", cause, someInfo, null, null, __tsplusTrace);
}
/**
 * Logs the specified message and cause at the informational log level.
 *
 * @tsplus static ets/Effect/Ops logInfoCauseMessage
 */


function logInfoCauseMessage(message, cause, __tsplusTrace) {
  return new _primitives.ILogged(message, cause, someInfo, null, null, __tsplusTrace);
}
/**
 * Logs the specified message at the warning log level.
 *
 * @tsplus static ets/Effect/Ops logWarning
 */


function logWarning(message, __tsplusTrace) {
  return new _primitives.ILogged(message, () => tsplus_module_3.empty, someWarning, null, null, __tsplusTrace);
}
/**
 * Logs the specified cause at the warning log level.
 *
 * @tsplus static ets/Effect/Ops logWarningCause
 */


function logWarningCause(cause, __tsplusTrace) {
  return new _primitives.ILogged(() => "", cause, someWarning, null, null, __tsplusTrace);
}
/**
 * Logs the specified message and cause at the warning log level.
 *
 * @tsplus static ets/Effect/Ops logWarningCauseMessage
 */


function logWarningCauseMessage(message, cause, __tsplusTrace) {
  return new _primitives.ILogged(message, cause, someWarning, null, null, __tsplusTrace);
}
/**
 * Logs the specified message at the trace log level.
 *
 * @tsplus static ets/Effect/Ops logTrace
 */


function logTrace(message, __tsplusTrace) {
  return new _primitives.ILogged(message, () => tsplus_module_3.empty, someTrace, null, null, __tsplusTrace);
}
/**
 * Logs the specified cause at the trace log level.
 *
 * @tsplus static ets/Effect/Ops logTraceCause
 */


function logTraceCause(cause, __tsplusTrace) {
  return new _primitives.ILogged(() => "", cause, someTrace, null, null, __tsplusTrace);
}
/**
 * Logs the specified message and cause at the trace log level.
 *
 * @tsplus static ets/Effect/Ops logTraceCauseMessage
 */


function logTraceCauseMessage(message, cause, __tsplusTrace) {
  return new _primitives.ILogged(message, cause, someTrace, null, null, __tsplusTrace);
}
/**
 * Adjusts the label for the current logging span.
 *
 * @tsplus static ets/Effect/Ops logSpan
 */


function logSpan(label) {
  return (effect, __tsplusTrace) => tsplus_module_10.flatMap_(tsplus_module_9.get(tsplus_module_6.currentLogSpan.value, fileName_1 + ":233:38"), stack => tsplus_module_8.suspendSucceed(() => {
    const now = Date.now();
    const logSpan = tsplus_module_4.apply(label(), now);
    return tsplus_module_7.locally_(tsplus_module_6.currentLogSpan.value, tsplus_module_5.prepend_(stack, logSpan), fileName_1 + ":238:48")(effect);
  }, fileName_1 + ":234:28"), fileName_1 + ":233:48");
}
/**
 * Annotates each log in this effect with the specified log annotation.
 *
 * @tsplus static ets/Effect/Ops logAnnotate
 */


function logAnnotate(key, value) {
  return (effect, __tsplusTrace) => tsplus_module_10.flatMap_(tsplus_module_9.get(tsplus_module_12.currentLogAnnotations.value, fileName_1 + ":252:11"), annotations => tsplus_module_8.suspendSucceed(() => tsplus_module_7.locally_(tsplus_module_12.currentLogAnnotations.value, tsplus_module_11.set_(annotations, key(), value()), fileName_1 + ":256:57")(effect), fileName_1 + ":254:30"), fileName_1 + ":253:15");
}
/**
 * Retrieves the log annotations associated with the current scope.
 *
 * @tsplus static ets/Effect/Ops logAnnotations
 */


function logAnnotations(__tsplusTrace) {
  return tsplus_module_9.get(tsplus_module_12.currentLogAnnotations.value, __tsplusTrace);
}
/**
 * An aspect that disables logging for the specified effect.
 *
 * @tsplus static ets/Effect/Ops disableLogging
 */


function disableLogging(effect) {
  return tsplus_module_10.flatMap_(tsplus_module_16.runtimeConfig, runtimeConfig => tsplus_module_15.withRuntimeConfig(() => tsplus_module_14.make({ ...runtimeConfig.value,
    loggers: tsplus_module_13.empty()
  }), () => effect, fileName_1 + ":280:29"), fileName_1 + ":279:38");
}
//# sourceMappingURL=logging.js.map