0.4.0-dev-2 #61
@ -4,7 +4,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "hep.dataforge"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0-dev-1"
|
||||
|
||||
apply<org.jetbrains.dokka.gradle.DokkaPlugin>()
|
||||
}
|
||||
@ -25,4 +25,8 @@ ksciencePublish {
|
||||
bintrayRepo = "dataforge"
|
||||
githubProject = "dataforge-core"
|
||||
spaceRepo = "https://maven.jetbrains.space/mipt-npm/p/df/maven"
|
||||
}
|
||||
|
||||
apiValidation{
|
||||
nonPublicMarkers.add("hep.dataforge.misc.DFExperimental")
|
||||
}
|
@ -93,15 +93,53 @@ public final class hep/dataforge/context/Global : hep/dataforge/context/Context
|
||||
public static synthetic fun context$default (Lhep/dataforge/context/Global;Ljava/lang/String;Lhep/dataforge/context/Context;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lhep/dataforge/context/Context;
|
||||
public final fun getContext (Ljava/lang/String;)Lhep/dataforge/context/Context;
|
||||
public fun getCoroutineContext ()Lkotlin/coroutines/CoroutineContext;
|
||||
public final fun getLogger ()Lhep/dataforge/context/LogManager;
|
||||
}
|
||||
|
||||
public final class hep/dataforge/context/LoggingJvmKt {
|
||||
public static final fun buildLogger (Lhep/dataforge/context/Context;Ljava/lang/String;)Lmu/KLogger;
|
||||
public final class hep/dataforge/context/KLoggingManager : hep/dataforge/context/AbstractPlugin, hep/dataforge/context/LogManager {
|
||||
public static final field Companion Lhep/dataforge/context/KLoggingManager$Companion;
|
||||
public fun <init> ()V
|
||||
public fun getTag ()Lhep/dataforge/context/PluginTag;
|
||||
public fun log (Lhep/dataforge/names/Name;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V
|
||||
}
|
||||
|
||||
public final class hep/dataforge/context/LoggingKt {
|
||||
public static final fun getLogger (Lhep/dataforge/context/Context;)Lmu/KLogger;
|
||||
public static final fun getLogger (Lhep/dataforge/context/ContextAware;)Lmu/KLogger;
|
||||
public final class hep/dataforge/context/KLoggingManager$Companion : hep/dataforge/context/PluginFactory {
|
||||
public fun getTag ()Lhep/dataforge/context/PluginTag;
|
||||
public fun getType ()Lkotlin/reflect/KClass;
|
||||
public fun invoke (Lhep/dataforge/meta/Meta;Lhep/dataforge/context/Context;)Lhep/dataforge/context/KLoggingManager;
|
||||
public synthetic fun invoke (Lhep/dataforge/meta/Meta;Lhep/dataforge/context/Context;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public abstract interface class hep/dataforge/context/LogManager : hep/dataforge/context/Plugin {
|
||||
public static final field Companion Lhep/dataforge/context/LogManager$Companion;
|
||||
public static final field DEBUG Ljava/lang/String;
|
||||
public static final field ERROR Ljava/lang/String;
|
||||
public static final field INFO Ljava/lang/String;
|
||||
public static final field TRACE Ljava/lang/String;
|
||||
public static final field WARNING Ljava/lang/String;
|
||||
public abstract fun log (Lhep/dataforge/names/Name;Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V
|
||||
}
|
||||
|
||||
public final class hep/dataforge/context/LogManager$Companion {
|
||||
public static final field DEBUG Ljava/lang/String;
|
||||
public static final field ERROR Ljava/lang/String;
|
||||
public static final field INFO Ljava/lang/String;
|
||||
public static final field TRACE Ljava/lang/String;
|
||||
public static final field WARNING Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class hep/dataforge/context/LogManager$DefaultImpls {
|
||||
public static fun content (Lhep/dataforge/context/LogManager;Ljava/lang/String;)Ljava/util/Map;
|
||||
public static fun getDefaultChainTarget (Lhep/dataforge/context/LogManager;)Ljava/lang/String;
|
||||
public static fun getDefaultTarget (Lhep/dataforge/context/LogManager;)Ljava/lang/String;
|
||||
public static fun getName (Lhep/dataforge/context/LogManager;)Lhep/dataforge/names/Name;
|
||||
public static fun toMeta (Lhep/dataforge/context/LogManager;)Lhep/dataforge/meta/Meta;
|
||||
}
|
||||
|
||||
public final class hep/dataforge/context/LogManagerKt {
|
||||
public static final fun getLogger (Lhep/dataforge/context/Context;)Lhep/dataforge/context/LogManager;
|
||||
public static final fun info (Lhep/dataforge/context/LogManager;Lhep/dataforge/names/Name;Lkotlin/jvm/functions/Function0;)V
|
||||
public static synthetic fun info$default (Lhep/dataforge/context/LogManager;Lhep/dataforge/names/Name;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V
|
||||
}
|
||||
|
||||
public abstract interface class hep/dataforge/context/Plugin : hep/dataforge/context/ContextAware, hep/dataforge/meta/MetaRepr, hep/dataforge/misc/Named, hep/dataforge/provider/Provider {
|
||||
@ -188,7 +226,6 @@ public final class hep/dataforge/context/PluginTag$Companion {
|
||||
public final class hep/dataforge/context/ResolveKt {
|
||||
public static final fun gather (Lhep/dataforge/context/Context;Ljava/lang/String;Lkotlin/reflect/KClass;Z)Ljava/util/Map;
|
||||
public static synthetic fun gather$default (Lhep/dataforge/context/Context;Ljava/lang/String;Lkotlin/reflect/KClass;ZILjava/lang/Object;)Ljava/util/Map;
|
||||
public static final fun gatherInSequence (Lhep/dataforge/context/Context;Ljava/lang/String;Lkotlin/reflect/KClass;Z)Lkotlin/sequences/Sequence;
|
||||
public static synthetic fun gatherInSequence$default (Lhep/dataforge/context/Context;Ljava/lang/String;Lkotlin/reflect/KClass;ZILjava/lang/Object;)Lkotlin/sequences/Sequence;
|
||||
public static final fun getValues (Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;
|
||||
public static final fun resolve (Lhep/dataforge/context/Context;Ljava/lang/String;Lhep/dataforge/names/Name;Lkotlin/reflect/KClass;)Ljava/lang/Object;
|
||||
@ -216,33 +253,12 @@ public abstract interface annotation class hep/dataforge/descriptors/ValueDef :
|
||||
public abstract fun type ()[Lhep/dataforge/values/ValueType;
|
||||
}
|
||||
|
||||
public final class hep/dataforge/properties/ConfigProperty : hep/dataforge/properties/Property {
|
||||
public fun <init> (Lhep/dataforge/meta/Config;Lhep/dataforge/names/Name;Lhep/dataforge/meta/transformations/MetaConverter;)V
|
||||
public final fun getConfig ()Lhep/dataforge/meta/Config;
|
||||
public final fun getConverter ()Lhep/dataforge/meta/transformations/MetaConverter;
|
||||
public final fun getName ()Lhep/dataforge/names/Name;
|
||||
public fun getValue ()Ljava/lang/Object;
|
||||
public fun onChange (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)V
|
||||
public fun removeChangeListener (Ljava/lang/Object;)V
|
||||
public fun setValue (Ljava/lang/Object;)V
|
||||
}
|
||||
|
||||
public abstract interface class hep/dataforge/properties/Property {
|
||||
public abstract fun getValue ()Ljava/lang/Object;
|
||||
public abstract fun onChange (Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)V
|
||||
public abstract fun removeChangeListener (Ljava/lang/Object;)V
|
||||
public abstract fun setValue (Ljava/lang/Object;)V
|
||||
}
|
||||
|
||||
public final class hep/dataforge/properties/Property$DefaultImpls {
|
||||
public static synthetic fun onChange$default (Lhep/dataforge/properties/Property;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||
public static synthetic fun removeChangeListener$default (Lhep/dataforge/properties/Property;Ljava/lang/Object;ILjava/lang/Object;)V
|
||||
}
|
||||
|
||||
public final class hep/dataforge/properties/PropertyKt {
|
||||
public static final fun bind (Lhep/dataforge/properties/Property;Lhep/dataforge/properties/Property;)V
|
||||
public static final fun mirror (Lhep/dataforge/properties/Property;Lhep/dataforge/properties/Property;Lkotlinx/coroutines/CoroutineScope;)V
|
||||
public static final fun toFlow (Lhep/dataforge/properties/Property;)Lkotlinx/coroutines/flow/StateFlow;
|
||||
}
|
||||
|
||||
public final class hep/dataforge/provider/DfTypeKt {
|
||||
|
@ -28,16 +28,6 @@ kotlin {
|
||||
api("io.github.microutils:kotlin-logging-js:2.0.4")
|
||||
}
|
||||
}
|
||||
//
|
||||
// val nativeMain by getting{
|
||||
// dependsOn(commonMain)
|
||||
// }
|
||||
// val mingwX64Main by getting{
|
||||
// dependsOn(nativeMain)
|
||||
// }
|
||||
// val linuxX64Main by getting{
|
||||
// dependsOn(nativeMain)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,9 @@ import kotlinx.coroutines.SupervisorJob
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
import kotlin.native.concurrent.ThreadLocal
|
||||
|
||||
|
||||
internal expect val globalLogger: LogManager
|
||||
|
||||
/**
|
||||
* A global root context. Closing [Global] terminates the framework.
|
||||
*/
|
||||
@ -15,6 +18,11 @@ public object Global : Context("GLOBAL".asName(), null, Meta.EMPTY) {
|
||||
|
||||
override val coroutineContext: CoroutineContext = GlobalScope.coroutineContext + SupervisorJob()
|
||||
|
||||
/**
|
||||
* The default logging manager
|
||||
*/
|
||||
public val logger: LogManager = globalLogger
|
||||
|
||||
/**
|
||||
* Closing all contexts
|
||||
*
|
||||
|
@ -0,0 +1,38 @@
|
||||
package hep.dataforge.context
|
||||
|
||||
import hep.dataforge.names.Name
|
||||
|
||||
public interface LogManager : Plugin {
|
||||
|
||||
public fun log(name: Name, tag: String, body: () -> String)
|
||||
|
||||
public companion object {
|
||||
public const val TRACE: String = "TRACE"
|
||||
public const val INFO: String = "INFO"
|
||||
public const val DEBUG: String = "DEBUG"
|
||||
public const val WARNING: String = "WARNING"
|
||||
public const val ERROR: String = "ERROR"
|
||||
}
|
||||
}
|
||||
|
||||
public fun LogManager.info(name: Name = Name.EMPTY, body: () -> String): Unit = log(name,LogManager.INFO,body)
|
||||
|
||||
public val Context.logger: LogManager
|
||||
get() = plugins.find(inherit = true) { it is LogManager } as? LogManager ?: Global.logger
|
||||
|
||||
|
||||
///**
|
||||
// * The logger specific to this context
|
||||
// */
|
||||
//public val Context.logger: Logger get() = buildLogger(name.toString())
|
||||
//
|
||||
///**
|
||||
// * The logger
|
||||
// */
|
||||
//public val ContextAware.logger: Logger
|
||||
// get() = if (this is Named) {
|
||||
// context.buildLogger(Path(context.name, this.name).toString())
|
||||
// } else {
|
||||
// context.logger
|
||||
// }
|
||||
|
@ -93,7 +93,7 @@ public class PluginManager(override val context: Context) : ContextAware, Iterab
|
||||
fetch(factory, meta, true)
|
||||
}
|
||||
|
||||
logger.info { "Loading plugin ${plugin.name} into ${context.name}" }
|
||||
Global.logger.info { "Loading plugin ${plugin.name} into ${context.name}" }
|
||||
plugin.attach(context)
|
||||
plugins.add(plugin)
|
||||
return plugin
|
||||
@ -114,7 +114,7 @@ public class PluginManager(override val context: Context) : ContextAware, Iterab
|
||||
*/
|
||||
public fun remove(plugin: Plugin) {
|
||||
if (plugins.contains(plugin)) {
|
||||
logger.info { "Removing plugin ${plugin.name} from ${context.name}" }
|
||||
Global.logger.info { "Removing plugin ${plugin.name} from ${context.name}" }
|
||||
plugin.detach()
|
||||
plugins.remove(plugin)
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
package hep.dataforge.context
|
||||
|
||||
import hep.dataforge.misc.Named
|
||||
import hep.dataforge.provider.Path
|
||||
|
||||
/**
|
||||
* Part of kotlin-logging interface
|
||||
*/
|
||||
public expect interface Logger {
|
||||
public fun trace(msg: () -> Any?)
|
||||
public fun debug(msg: () -> Any?)
|
||||
public fun info(msg: () -> Any?)
|
||||
public fun warn(msg: () -> Any?)
|
||||
public fun error(msg: () -> Any?)
|
||||
}
|
||||
|
||||
public expect fun Context.buildLogger(name: String): Logger
|
||||
|
||||
/**
|
||||
* The logger specific to this context
|
||||
*/
|
||||
public val Context.logger: Logger get() = buildLogger(name.toString())
|
||||
|
||||
/**
|
||||
* The logger
|
||||
*/
|
||||
public val ContextAware.logger: Logger
|
||||
get() = if (this is Named) {
|
||||
context.buildLogger(Path(context.name, this.name).toString())
|
||||
} else {
|
||||
context.logger
|
||||
}
|
||||
|
@ -1,8 +1,31 @@
|
||||
package hep.dataforge.context
|
||||
|
||||
import mu.KLogger
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.names.Name
|
||||
import mu.KotlinLogging
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public actual typealias Logger = KLogger
|
||||
public class KLoggingManager : AbstractPlugin(), LogManager {
|
||||
|
||||
public actual fun Context.buildLogger(name: String): Logger = KotlinLogging.logger(name)
|
||||
override fun log(name: Name, tag: String, body: () -> String) {
|
||||
val logger = KotlinLogging.logger("[${context.name}] $name")
|
||||
when (tag) {
|
||||
LogManager.DEBUG -> logger.debug(body)
|
||||
LogManager.INFO -> logger.info(body)
|
||||
LogManager.WARNING -> logger.warn(body)
|
||||
LogManager.ERROR -> logger.error(body)
|
||||
else -> logger.trace(body)
|
||||
}
|
||||
}
|
||||
|
||||
override val tag: PluginTag get() = Companion.tag
|
||||
|
||||
public companion object : PluginFactory<KLoggingManager> {
|
||||
override fun invoke(meta: Meta, context: Context): KLoggingManager = KLoggingManager()
|
||||
|
||||
override val tag: PluginTag = PluginTag(group = PluginTag.DATAFORGE_GROUP, name = "log.kotlinLogging")
|
||||
override val type: KClass<out KLoggingManager> = KLoggingManager::class
|
||||
}
|
||||
}
|
||||
|
||||
internal actual val globalLogger: LogManager = KLoggingManager().apply { attach(Global) }
|
||||
|
@ -1,8 +1,31 @@
|
||||
package hep.dataforge.context
|
||||
|
||||
import mu.KLogger
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.names.Name
|
||||
import mu.KotlinLogging
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public actual typealias Logger = KLogger
|
||||
public class KLoggingManager : AbstractPlugin(), LogManager {
|
||||
|
||||
public actual fun Context.buildLogger(name: String): Logger = KotlinLogging.logger(name)
|
||||
override fun log(name: Name, tag: String, body: () -> String) {
|
||||
val logger = KotlinLogging.logger("[${context.name}] $name")
|
||||
when (tag) {
|
||||
LogManager.DEBUG -> logger.debug(body)
|
||||
LogManager.INFO -> logger.info(body)
|
||||
LogManager.WARNING -> logger.warn(body)
|
||||
LogManager.ERROR -> logger.error(body)
|
||||
else -> logger.trace(body)
|
||||
}
|
||||
}
|
||||
|
||||
override val tag: PluginTag get() = Companion.tag
|
||||
|
||||
public companion object : PluginFactory<KLoggingManager> {
|
||||
override fun invoke(meta: Meta, context: Context): KLoggingManager = KLoggingManager()
|
||||
|
||||
override val tag: PluginTag = PluginTag(group = PluginTag.DATAFORGE_GROUP, name = "log.kotlinLogging")
|
||||
override val type: KClass<out KLoggingManager> = KLoggingManager::class
|
||||
}
|
||||
}
|
||||
|
||||
internal actual val globalLogger: LogManager = KLoggingManager().apply { attach(Global) }
|
||||
|
@ -1,53 +1,29 @@
|
||||
package hep.dataforge.context
|
||||
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.names.Name
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public actual interface Logger {
|
||||
/**
|
||||
* Lazy add a log message if isTraceEnabled is true
|
||||
*/
|
||||
public actual fun trace(msg: () -> Any?)
|
||||
|
||||
/**
|
||||
* Lazy add a log message if isDebugEnabled is true
|
||||
*/
|
||||
public actual fun debug(msg: () -> Any?)
|
||||
public class NativeLogManager : AbstractPlugin(), LogManager {
|
||||
|
||||
/**
|
||||
* Lazy add a log message if isInfoEnabled is true
|
||||
*/
|
||||
public actual fun info(msg: () -> Any?)
|
||||
override fun log(name: Name, tag: String, body: () -> String) {
|
||||
val text = try {
|
||||
body()
|
||||
} catch (t: Throwable){
|
||||
"Error while evaluating log string: ${t.message}"
|
||||
}
|
||||
println("[${context.name}] $name: $text")
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy add a log message if isWarnEnabled is true
|
||||
*/
|
||||
public actual fun warn(msg: () -> Any?)
|
||||
override val tag: PluginTag get() = Companion.tag
|
||||
|
||||
/**
|
||||
* Lazy add a log message if isErrorEnabled is true
|
||||
*/
|
||||
public actual fun error(msg: () -> Any?)
|
||||
public companion object : PluginFactory<NativeLogManager> {
|
||||
override fun invoke(meta: Meta, context: Context): NativeLogManager = NativeLogManager()
|
||||
|
||||
override val tag: PluginTag = PluginTag(group = PluginTag.DATAFORGE_GROUP, name = "log.native")
|
||||
override val type: KClass<out NativeLogManager> = NativeLogManager::class
|
||||
}
|
||||
}
|
||||
|
||||
public actual fun Context.buildLogger(name: String): Logger = object :Logger{
|
||||
override fun trace(msg: () -> Any?) {
|
||||
println("[TRACE] $name - ${msg()}")
|
||||
}
|
||||
|
||||
override fun debug(msg: () -> Any?) {
|
||||
println("[DEBUG] $name - ${msg()}")
|
||||
}
|
||||
|
||||
override fun info(msg: () -> Any?) {
|
||||
println("[INFO] $name - ${msg()}")
|
||||
}
|
||||
|
||||
override fun warn(msg: () -> Any?) {
|
||||
println("[WARNING] $name - ${msg()}")
|
||||
}
|
||||
|
||||
override fun error(msg: () -> Any?) {
|
||||
println("[ERROR] $name - ${msg()}")
|
||||
}
|
||||
|
||||
}
|
||||
internal actual val globalLogger: LogManager = NativeLogManager().apply { attach(Global) }
|
||||
|
@ -175,7 +175,6 @@ public final class hep/dataforge/meta/LaminateKt {
|
||||
public final class hep/dataforge/meta/MapMetaKt {
|
||||
public static final fun toMap (Lhep/dataforge/meta/Meta;Lhep/dataforge/meta/descriptors/NodeDescriptor;)Ljava/util/Map;
|
||||
public static synthetic fun toMap$default (Lhep/dataforge/meta/Meta;Lhep/dataforge/meta/descriptors/NodeDescriptor;ILjava/lang/Object;)Ljava/util/Map;
|
||||
public static final fun toMeta (Ljava/util/Map;Lhep/dataforge/meta/descriptors/NodeDescriptor;)Lhep/dataforge/meta/Meta;
|
||||
public static synthetic fun toMeta$default (Ljava/util/Map;Lhep/dataforge/meta/descriptors/NodeDescriptor;ILjava/lang/Object;)Lhep/dataforge/meta/Meta;
|
||||
}
|
||||
|
||||
@ -417,7 +416,6 @@ public final class hep/dataforge/meta/MutableMeta$DefaultImpls {
|
||||
public final class hep/dataforge/meta/MutableMetaKt {
|
||||
public static final fun append (Lhep/dataforge/meta/MutableItemProvider;Lhep/dataforge/names/Name;Ljava/lang/Object;)V
|
||||
public static final fun append (Lhep/dataforge/meta/MutableItemProvider;Ljava/lang/String;Ljava/lang/Object;)V
|
||||
public static final fun edit (Lhep/dataforge/meta/AbstractMutableMeta;Lhep/dataforge/names/Name;Lkotlin/jvm/functions/Function1;)V
|
||||
}
|
||||
|
||||
public abstract interface class hep/dataforge/meta/ObservableItemProvider : hep/dataforge/meta/ItemProvider {
|
||||
@ -662,7 +660,6 @@ public final class hep/dataforge/meta/transformations/MetaTransformation {
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public static fun equals-impl (Ljava/util/Collection;Ljava/lang/Object;)Z
|
||||
public static final fun equals-impl0 (Ljava/util/Collection;Ljava/util/Collection;)Z
|
||||
public static final fun generate-impl (Ljava/util/Collection;Lhep/dataforge/meta/Config;)Lhep/dataforge/meta/ObservableItemProvider;
|
||||
public static final fun generate-impl (Ljava/util/Collection;Lhep/dataforge/meta/Meta;)Lhep/dataforge/meta/Meta;
|
||||
public final fun getTransformations ()Ljava/util/Collection;
|
||||
public fun hashCode ()I
|
||||
@ -805,9 +802,7 @@ public final class hep/dataforge/names/NameKt {
|
||||
}
|
||||
|
||||
public final class hep/dataforge/names/NameMatcherKt {
|
||||
public static final fun matches (Lhep/dataforge/names/Name;Lhep/dataforge/names/Name;)Z
|
||||
public static final fun matches (Lhep/dataforge/names/Name;Ljava/lang/String;)Z
|
||||
public static final fun matches (Lhep/dataforge/names/NameToken;Lhep/dataforge/names/NameToken;)Z
|
||||
}
|
||||
|
||||
public final class hep/dataforge/names/NameToken {
|
||||
|
Loading…
Reference in New Issue
Block a user