@kform/core
Version:
JavaScript bindings for KForm.
448 lines (446 loc) • 14.2 kB
JavaScript
import {
Unit_instance14hm69wy3kr8u as Unit_instance,
VOID7hggqo3abtya as VOID,
initMetadataForInterface1egvbzx539z91 as initMetadataForInterface,
initMetadataForClassbxx6q50dy2s7 as initMetadataForClass,
initMetadataForObject1cxne3s9w65el as initMetadataForObject,
THROW_IAE23kobfj9wdoxr as THROW_IAE,
Enum3alwj03lh1n41 as Enum,
toString30pk9tzaqopn as toString,
Exceptiondt2hlxn7j7vw as Exception,
equals2au1ep9vhcato as equals,
StringBuildermazzzhj6kkai as StringBuilder,
createThis2j2avj17cvnv2 as createThis,
hashCodeq5arwsb9dgti as hashCode,
getStringHashCode26igk1bx568vk as getStringHashCode,
THROW_CCE2g6jy02ryeudk as THROW_CCE,
protoOf180f3jzyo7rfj as protoOf,
noWhenBranchMatchedException2a6r7ubxgky5j as noWhenBranchMatchedException,
stackTraceToString2670q6lbhdojj as stackTraceToString,
split2bvyvnrlcifjv as split,
substringBeforekje8w2lxhyb6 as substringBefore,
substringAfterLastuw9v7gfiiihe as substringAfterLast,
contains3ue2qo8xhmpf1 as contains,
} from './kotlin-kotlin-stdlib.mjs';
//region block: imports
var imul = Math.imul;
//endregion
//region block: pre-declaration
class KLogger {}
function trace(message) {
var tmp = Level_TRACE_getInstance();
return this.vz(tmp, VOID, KLogger$trace$lambda(message));
}
function debug(message) {
var tmp = Level_DEBUG_getInstance();
return this.vz(tmp, VOID, KLogger$debug$lambda(message));
}
function error(throwable, message) {
var tmp = Level_ERROR_getInstance();
return this.vz(tmp, VOID, KLogger$error$lambda(message, throwable));
}
function at$default(level, marker, block, $super) {
marker = marker === VOID ? null : marker;
var tmp;
if ($super === VOID) {
this.yz(level, marker, block);
tmp = Unit_instance;
} else {
tmp = $super.yz.call(this, level, marker, block);
}
return tmp;
}
function isDebugEnabled(marker) {
return this.a10(Level_DEBUG_getInstance(), marker);
}
function isDebugEnabled$default(marker, $super) {
marker = marker === VOID ? null : marker;
return $super === VOID ? this.zz(marker) : isDebugEnabled(marker);
}
class KLoggingEventBuilder {
constructor() {
this.pz_1 = null;
this.qz_1 = null;
this.rz_1 = null;
this.sz_1 = null;
this.tz_1 = null;
}
}
class KotlinLogging {
c10(func) {
return this.e10(KLoggerNameResolver_instance.d10(func));
}
e10(name) {
return KLoggerFactory_instance.e10(name);
}
}
class Level extends Enum {
constructor(name, ordinal, levelInt, levelStr) {
super(name, ordinal);
this.h10_1 = levelInt;
this.i10_1 = levelStr;
}
toString() {
return this.i10_1;
}
}
class DefaultErrorMessageProducer {
j10(e) {
return 'Log message invocation failed: ' + e.toString();
}
}
class FormattingAppender {
l10(loggingEvent) {
// Inline function 'kotlin.let' call
// Inline function 'io.github.oshai.kotlinlogging.FormattingAppender.log.<anonymous>' call
var it = KotlinLoggingConfiguration_getInstance().n10_1.p10(loggingEvent);
this.k10(loggingEvent, it);
}
}
class DefaultMessageFormatter {
constructor(includePrefix) {
includePrefix = includePrefix === VOID ? true : includePrefix;
this.q10_1 = includePrefix;
}
p10(loggingEvent) {
// Inline function 'kotlin.with' call
// Inline function 'kotlin.text.buildString' call
// Inline function 'kotlin.apply' call
var this_0 = StringBuilder.u();
// Inline function 'io.github.oshai.kotlinlogging.DefaultMessageFormatter.formatMessage.<anonymous>.<anonymous>' call
this_0.xc(prefix(this, loggingEvent.r10_1, loggingEvent.t10_1));
var tmp0_safe_receiver = loggingEvent.s10_1;
var tmp1_safe_receiver = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.x10();
if (tmp1_safe_receiver == null)
null;
else {
// Inline function 'kotlin.let' call
// Inline function 'io.github.oshai.kotlinlogging.DefaultMessageFormatter.formatMessage.<anonymous>.<anonymous>.<anonymous>' call
this_0.xc(tmp1_safe_receiver);
this_0.xc(' ');
}
this_0.xc(loggingEvent.u10_1);
this_0.xc(throwableToString(loggingEvent.v10_1, this));
return this_0.toString();
}
}
class KLoggingEvent {
static y10(level, marker, loggerName, message, cause, payload) {
message = message === VOID ? null : message;
cause = cause === VOID ? null : cause;
payload = payload === VOID ? null : payload;
var $this = createThis(this);
$this.r10_1 = level;
$this.s10_1 = marker;
$this.t10_1 = loggerName;
$this.u10_1 = message;
$this.v10_1 = cause;
$this.w10_1 = payload;
return $this;
}
static z10(level, marker, loggerName, eventBuilder) {
return this.y10(level, marker, loggerName, eventBuilder.pz_1, eventBuilder.qz_1, eventBuilder.rz_1);
}
toString() {
return 'KLoggingEvent(level=' + this.r10_1.toString() + ', marker=' + toString(this.s10_1) + ', loggerName=' + this.t10_1 + ', message=' + this.u10_1 + ', cause=' + toString(this.v10_1) + ', payload=' + toString(this.w10_1) + ')';
}
hashCode() {
var result = this.r10_1.hashCode();
result = imul(result, 31) + (this.s10_1 == null ? 0 : hashCode(this.s10_1)) | 0;
result = imul(result, 31) + getStringHashCode(this.t10_1) | 0;
result = imul(result, 31) + (this.u10_1 == null ? 0 : getStringHashCode(this.u10_1)) | 0;
result = imul(result, 31) + (this.v10_1 == null ? 0 : hashCode(this.v10_1)) | 0;
result = imul(result, 31) + (this.w10_1 == null ? 0 : hashCode(this.w10_1)) | 0;
return result;
}
equals(other) {
if (this === other)
return true;
if (!(other instanceof KLoggingEvent))
return false;
var tmp0_other_with_cast = other instanceof KLoggingEvent ? other : THROW_CCE();
if (!this.r10_1.equals(tmp0_other_with_cast.r10_1))
return false;
if (!equals(this.s10_1, tmp0_other_with_cast.s10_1))
return false;
if (!(this.t10_1 === tmp0_other_with_cast.t10_1))
return false;
if (!(this.u10_1 == tmp0_other_with_cast.u10_1))
return false;
if (!equals(this.v10_1, tmp0_other_with_cast.v10_1))
return false;
if (!equals(this.w10_1, tmp0_other_with_cast.w10_1))
return false;
return true;
}
}
class KLoggerDirect {
constructor(name) {
this.a11_1 = name;
}
yz(level, marker, block) {
if (this.a10(level, marker)) {
// Inline function 'kotlin.apply' call
var this_0 = new KLoggingEventBuilder();
block(this_0);
// Inline function 'kotlin.run' call
// Inline function 'io.github.oshai.kotlinlogging.internal.KLoggerDirect.at.<anonymous>' call
if (level.h3_1 !== 5) {
KotlinLoggingConfiguration_getInstance().o10_1.l10(KLoggingEvent.z10(level, marker, this.a11_1, this_0));
}
}
}
a10(level, marker) {
return isLoggingEnabled(level);
}
}
class KLoggerFactory {
e10(name) {
return new KLoggerDirect(name);
}
}
class ConsoleOutputAppender extends FormattingAppender {
k10(loggingEvent, formattedMessage) {
switch (loggingEvent.r10_1.h3_1) {
case 0:
console.log(formattedMessage);
break;
case 1:
console.log(formattedMessage);
break;
case 2:
console.info(formattedMessage);
break;
case 3:
console.warn(formattedMessage);
break;
case 4:
console.error(formattedMessage);
break;
case 5:
break;
default:
noWhenBranchMatchedException();
break;
}
}
}
class KotlinLoggingConfiguration {
constructor() {
KotlinLoggingConfiguration_instance = this;
this.m10_1 = Level_INFO_getInstance();
this.n10_1 = new DefaultMessageFormatter(true);
this.o10_1 = new ConsoleOutputAppender();
}
}
class KLoggerNameResolver {
d10(func) {
var found = false;
var exception = Exception.ue();
var _iterator__ex2g4s = split(stackTraceToString(exception), ['\n']).y();
while (_iterator__ex2g4s.z()) {
var line = _iterator__ex2g4s.a1();
if (found) {
return substringAfterLast(substringAfterLast(substringBefore(line, '.kt'), '.'), '/');
}
if (contains(line, 'at KotlinLogging')) {
found = true;
}
}
return '';
}
}
//endregion
function KLogger$trace$lambda($message) {
return ($this$at) => {
$this$at.pz_1 = toStringSafe($message);
return Unit_instance;
};
}
function KLogger$debug$lambda($message) {
return ($this$at) => {
$this$at.pz_1 = toStringSafe($message);
return Unit_instance;
};
}
function KLogger$error$lambda($message, $throwable) {
return ($this$at) => {
$this$at.pz_1 = toStringSafe($message);
$this$at.qz_1 = $throwable;
return Unit_instance;
};
}
var KotlinLogging_instance;
function KotlinLogging_getInstance() {
return KotlinLogging_instance;
}
var Level_TRACE_instance;
var Level_DEBUG_instance;
var Level_INFO_instance;
var Level_WARN_instance;
var Level_ERROR_instance;
var Level_OFF_instance;
function valueOf(value) {
switch (value) {
case 'TRACE':
return Level_TRACE_getInstance();
case 'DEBUG':
return Level_DEBUG_getInstance();
case 'INFO':
return Level_INFO_getInstance();
case 'WARN':
return Level_WARN_getInstance();
case 'ERROR':
return Level_ERROR_getInstance();
case 'OFF':
return Level_OFF_getInstance();
default:
Level_initEntries();
THROW_IAE('No enum constant value.');
break;
}
}
var Level_entriesInitialized;
function Level_initEntries() {
if (Level_entriesInitialized)
return Unit_instance;
Level_entriesInitialized = true;
Level_TRACE_instance = new Level('TRACE', 0, 0, 'TRACE');
Level_DEBUG_instance = new Level('DEBUG', 1, 10, 'DEBUG');
Level_INFO_instance = new Level('INFO', 2, 20, 'INFO');
Level_WARN_instance = new Level('WARN', 3, 30, 'WARN');
Level_ERROR_instance = new Level('ERROR', 4, 40, 'ERROR');
Level_OFF_instance = new Level('OFF', 5, 50, 'OFF');
}
function Level_TRACE_getInstance() {
Level_initEntries();
return Level_TRACE_instance;
}
function Level_DEBUG_getInstance() {
Level_initEntries();
return Level_DEBUG_instance;
}
function Level_INFO_getInstance() {
Level_initEntries();
return Level_INFO_instance;
}
function Level_WARN_getInstance() {
Level_initEntries();
return Level_WARN_instance;
}
function Level_ERROR_getInstance() {
Level_initEntries();
return Level_ERROR_instance;
}
function Level_OFF_getInstance() {
Level_initEntries();
return Level_OFF_instance;
}
function toStringSafe(_this__u8e3s4) {
var tmp;
try {
tmp = toString(_this__u8e3s4());
} catch ($p) {
var tmp_0;
if ($p instanceof Exception) {
var e = $p;
tmp_0 = DefaultErrorMessageProducer_instance.j10(e);
} else {
throw $p;
}
tmp = tmp_0;
}
return tmp;
}
var DefaultErrorMessageProducer_instance;
function DefaultErrorMessageProducer_getInstance() {
return DefaultErrorMessageProducer_instance;
}
function prefix($this, level, loggerName) {
var tmp;
if ($this.q10_1) {
tmp = level.g3_1 + ': [' + loggerName + '] ';
} else {
tmp = '';
}
return tmp;
}
function throwableToString(_this__u8e3s4, $this) {
return createThrowableMsg($this, '', _this__u8e3s4);
}
function createThrowableMsg($this, msg, throwable) {
var $this_0 = $this;
var msg_0 = msg;
var throwable_0 = throwable;
$l$1: do {
$l$0: do {
var tmp;
if (throwable_0 == null || equals(throwable_0.cause, throwable_0)) {
tmp = msg_0;
} else {
var tmp0 = $this_0;
var tmp1 = msg_0 + ", Caused by: '" + throwable_0.message + "'";
var tmp2 = throwable_0.cause;
$this_0 = tmp0;
msg_0 = tmp1;
throwable_0 = tmp2;
continue $l$0;
}
return tmp;
}
while (false);
}
while (true);
}
function isLoggingEnabled(_this__u8e3s4) {
return _this__u8e3s4.h3_1 >= KotlinLoggingConfiguration_getInstance().m10_1.h3_1;
}
var KLoggerFactory_instance;
function KLoggerFactory_getInstance() {
return KLoggerFactory_instance;
}
var KotlinLoggingConfiguration_instance;
function KotlinLoggingConfiguration_getInstance() {
if (KotlinLoggingConfiguration_instance === VOID)
new KotlinLoggingConfiguration();
return KotlinLoggingConfiguration_instance;
}
var KLoggerNameResolver_instance;
function KLoggerNameResolver_getInstance() {
return KLoggerNameResolver_instance;
}
//region block: post-declaration
initMetadataForInterface(KLogger, 'KLogger');
initMetadataForClass(KLoggingEventBuilder, 'KLoggingEventBuilder', KLoggingEventBuilder);
initMetadataForObject(KotlinLogging, 'KotlinLogging');
initMetadataForClass(Level, 'Level');
initMetadataForObject(DefaultErrorMessageProducer, 'DefaultErrorMessageProducer');
initMetadataForClass(FormattingAppender, 'FormattingAppender');
initMetadataForClass(DefaultMessageFormatter, 'DefaultMessageFormatter', DefaultMessageFormatter);
initMetadataForClass(KLoggingEvent, 'KLoggingEvent');
protoOf(KLoggerDirect).vz = at$default;
protoOf(KLoggerDirect).uz = trace;
protoOf(KLoggerDirect).wz = debug;
protoOf(KLoggerDirect).xz = error;
protoOf(KLoggerDirect).zz = isDebugEnabled;
protoOf(KLoggerDirect).b10 = isDebugEnabled$default;
initMetadataForClass(KLoggerDirect, 'KLoggerDirect', VOID, VOID, [KLogger]);
initMetadataForObject(KLoggerFactory, 'KLoggerFactory');
initMetadataForClass(ConsoleOutputAppender, 'ConsoleOutputAppender', ConsoleOutputAppender);
initMetadataForObject(KotlinLoggingConfiguration, 'KotlinLoggingConfiguration');
initMetadataForObject(KLoggerNameResolver, 'KLoggerNameResolver');
//endregion
//region block: init
KotlinLogging_instance = new KotlinLogging();
DefaultErrorMessageProducer_instance = new DefaultErrorMessageProducer();
KLoggerFactory_instance = new KLoggerFactory();
KLoggerNameResolver_instance = new KLoggerNameResolver();
//endregion
//region block: exports
export {
KotlinLoggingConfiguration_getInstance as KotlinLoggingConfiguration_getInstance2lt457yq87jkh,
KotlinLogging_instance as KotlinLogging_instance26prnimog2gu5,
valueOf as valueOf1uc4ed064hut4,
};
//endregion
//# sourceMappingURL=kotlin-logging.mjs.map