generated from rnentjes/kotlin-server-web-empty
Add logging functionality and Maven publishing setup
Added Logger class with various log levels to `commonMain`. Integrated `maven-publish` and `signing` plugins in `build.gradle.kts` to facilitate publishing artifacts to the Maven repository with proper credentials and metadata. Removed `gradle.properties` and updated `.gitignore` accordingly.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -44,3 +44,4 @@ bin/
|
||||
### .kotlin ###
|
||||
.kotlin
|
||||
kotlin-js-store
|
||||
gradle.properties
|
||||
|
||||
1
.idea/.name
generated
1
.idea/.name
generated
@@ -1 +0,0 @@
|
||||
template
|
||||
6
.idea/artifacts/kotlin_simple_logging_js_1_0_0_SNAPSHOT.xml
generated
Normal file
6
.idea/artifacts/kotlin_simple_logging_js_1_0_0_SNAPSHOT.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="kotlin-simple-logging-js-1.0.0-SNAPSHOT">
|
||||
<output-path>$PROJECT_DIR$/build/libs</output-path>
|
||||
<root id="archive" name="kotlin-simple-logging-js-1.0.0-SNAPSHOT.jar" />
|
||||
</artifact>
|
||||
</component>
|
||||
6
.idea/artifacts/kotlin_simple_logging_jvm_1_0_0_SNAPSHOT.xml
generated
Normal file
6
.idea/artifacts/kotlin_simple_logging_jvm_1_0_0_SNAPSHOT.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="kotlin-simple-logging-jvm-1.0.0-SNAPSHOT">
|
||||
<output-path>$PROJECT_DIR$/build/libs</output-path>
|
||||
<root id="archive" name="kotlin-simple-logging-jvm-1.0.0-SNAPSHOT.jar" />
|
||||
</artifact>
|
||||
</component>
|
||||
@@ -2,6 +2,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform") version "2.0.21"
|
||||
`maven-publish`
|
||||
signing
|
||||
}
|
||||
|
||||
group = "nl.astraeus"
|
||||
@@ -9,57 +11,65 @@ version = "1.0.0-SNAPSHOT"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = uri("https://gitea.astraeus.nl/api/packages/rnentjes/maven")
|
||||
}
|
||||
maven {
|
||||
url = uri("https://gitea.astraeus.nl:8443/api/packages/rnentjes/maven")
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
jvm {
|
||||
withJava()
|
||||
}
|
||||
js {
|
||||
binaries.executable()
|
||||
browser {
|
||||
distribution {
|
||||
outputDirectory.set(File("$projectDir/web/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
jvm {}
|
||||
js {}
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api("nl.astraeus:kotlin-css-generator:1.0.10")
|
||||
val commonMain by getting
|
||||
val jvmMain by getting
|
||||
val jsMain by getting
|
||||
}
|
||||
}
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")
|
||||
}
|
||||
}
|
||||
val commonTest by getting
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation("io.undertow:undertow-core:2.3.14.Final")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.11.0")
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "gitea"
|
||||
setUrl("https://gitea.astraeus.nl/api/packages/rnentjes/maven")
|
||||
|
||||
implementation("org.xerial:sqlite-jdbc:3.32.3.2")
|
||||
implementation("com.zaxxer:HikariCP:4.0.3")
|
||||
implementation("nl.astraeus:simple-jdbc-stats:1.6.1") {
|
||||
exclude(group = "org.slf4j", module = "slf4j-api")
|
||||
credentials() {
|
||||
val giteaUsername: kotlin.String? by project
|
||||
val giteaPassword: kotlin.String? by project
|
||||
|
||||
username = giteaUsername
|
||||
password = giteaPassword
|
||||
}
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
|
||||
// Configure all publications
|
||||
publications.withType<MavenPublication> {
|
||||
// Stub javadoc.jar artifact
|
||||
artifact(javadocJar.get())
|
||||
|
||||
// Provide artifacts information requited by Maven Central
|
||||
pom {
|
||||
name.set("kotlin-komponent")
|
||||
description.set("Kotlin komponent")
|
||||
url.set("https://github.com/rnentjes/komponent")
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set("MIT")
|
||||
url.set("https://opensource.org/licenses/MIT")
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation("nl.astraeus:kotlin-komponent:1.2.4")
|
||||
developers {
|
||||
developer {
|
||||
id.set("rnentjes")
|
||||
name.set("Rien Nentjes")
|
||||
email.set("info@nentjes.com")
|
||||
}
|
||||
}
|
||||
val jsTest by getting
|
||||
scm {
|
||||
url.set("https://github.com/rnentjes/komponent")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
sign(publishing.publications)
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
kotlin.code.style=official
|
||||
52
src/commonMain/kotlin/nl/astraeus/logger/Logger.kt
Normal file
52
src/commonMain/kotlin/nl/astraeus/logger/Logger.kt
Normal file
@@ -0,0 +1,52 @@
|
||||
package nl.astraeus.logger
|
||||
|
||||
enum class LogLevel {
|
||||
TRACE,
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARN,
|
||||
ERROR,
|
||||
FATAL
|
||||
}
|
||||
|
||||
class Logger(
|
||||
var level: LogLevel = LogLevel.INFO
|
||||
) {
|
||||
|
||||
fun trace(message: () -> String?) {
|
||||
if (level.ordinal <= LogLevel.TRACE.ordinal) {
|
||||
println("TRACE: ${message()}")
|
||||
}
|
||||
}
|
||||
|
||||
fun debug(message: () -> String?) {
|
||||
if (level.ordinal <= LogLevel.DEBUG.ordinal) {
|
||||
println("DEBUG: ${message()}")
|
||||
}
|
||||
}
|
||||
|
||||
fun info(message: () -> String?) {
|
||||
if (level.ordinal <= LogLevel.INFO.ordinal) {
|
||||
println("INFO: ${message()}")
|
||||
}
|
||||
}
|
||||
|
||||
fun warn(e: Throwable? = null, message: () -> String?) {
|
||||
if (level.ordinal <= LogLevel.WARN.ordinal) {
|
||||
println("WARN: ${message()}")
|
||||
e?.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun error(e: Throwable? = null, message: () -> String?) {
|
||||
if (level.ordinal <= LogLevel.ERROR.ordinal) {
|
||||
println("ERROR: ${message()}")
|
||||
e?.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun fatal(e: Throwable, message: () -> String?) {
|
||||
println("FATAL: ${message()}")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user