mirror of
https://github.com/InsanusMokrassar/KSLog.git
synced 2025-12-23 05:15:41 +00:00
generate kdocs
This commit is contained in:
@@ -2,23 +2,62 @@ package dev.inmo.kslog.common
|
||||
|
||||
import kotlin.js.Console
|
||||
|
||||
/**
|
||||
* Extended Console interface that includes additional console methods
|
||||
* not present in Kotlin's standard Console interface
|
||||
*
|
||||
* Provides access to browser/Node.js console methods like `debug`, `trace`, and `assert`.
|
||||
*/
|
||||
external interface ExtendedConsole : Console {
|
||||
/**
|
||||
* Outputs a stack trace to the console
|
||||
*/
|
||||
fun trace()
|
||||
|
||||
/**
|
||||
* Outputs a debug message to the console
|
||||
*
|
||||
* @param o Objects to output
|
||||
*/
|
||||
fun debug(vararg o: Any?)
|
||||
|
||||
/**
|
||||
* Writes an error message to the console if the assertion is false
|
||||
*
|
||||
* @param assertion Boolean condition to test
|
||||
* @param o Objects to output if assertion is false
|
||||
*/
|
||||
fun assert(assertion: Boolean, vararg o: Any?)
|
||||
}
|
||||
|
||||
/**
|
||||
* [https://developer.mozilla.org/en-US/docs/Web/API/console/debug_static](https://developer.mozilla.org/en-US/docs/Web/API/console/debug_static)
|
||||
* Extension function to output debug messages to the console
|
||||
*
|
||||
* Maps to the browser's `console.debug()` method.
|
||||
*
|
||||
* [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/console/debug_static)
|
||||
*
|
||||
* @param args Objects to output
|
||||
*/
|
||||
fun Console.debug(vararg args: Any?) = unsafeCast<ExtendedConsole>().debug(*args)
|
||||
|
||||
/**
|
||||
* [https://developer.mozilla.org/en-US/docs/Web/APtraceI/console/assert_static](https://developer.mozilla.org/en-US/docs/Web/API/console/assert_static)
|
||||
* Extension function to write an error message if assertion fails
|
||||
*
|
||||
* Maps to the browser's `console.assert()` method.
|
||||
*
|
||||
* [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/console/assert_static)
|
||||
*
|
||||
* @param assertion Boolean condition to test
|
||||
* @param args Objects to output if assertion is false
|
||||
*/
|
||||
fun Console.assert(assertion: Boolean, vararg args: Any?) = unsafeCast<ExtendedConsole>().assert(assertion, *args)
|
||||
|
||||
/**
|
||||
* [https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static](https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static)
|
||||
* Extension function to output a stack trace to the console
|
||||
*
|
||||
* Maps to the browser's `console.trace()` method.
|
||||
*
|
||||
* [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/console/trace_static)
|
||||
*/
|
||||
fun Console.trace() = unsafeCast<ExtendedConsole>().trace()
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
package dev.inmo.kslog.common
|
||||
|
||||
/**
|
||||
* JavaScript platform implementation of the default logger
|
||||
*
|
||||
* Uses browser/Node.js `console` API as the logging backend, mapping KSLog levels
|
||||
* to console methods:
|
||||
* - [LogLevel.TRACE] → console.trace() + console.debug()
|
||||
* - [LogLevel.DEBUG] → console.debug()
|
||||
* - [LogLevel.VERBOSE] → console.info()
|
||||
* - [LogLevel.INFO] → console.info()
|
||||
* - [LogLevel.WARNING] → console.warn()
|
||||
* - [LogLevel.ERROR] → console.error()
|
||||
* - [LogLevel.ASSERT] → console.error()
|
||||
*
|
||||
* Logs can be viewed in the browser's Developer Tools console or Node.js console output.
|
||||
*
|
||||
* **Note**: The tag parameter is ignored in JS implementation as console methods
|
||||
* don't support tagging natively.
|
||||
*/
|
||||
actual var KSLoggerDefaultPlatformLoggerLambda: (level: LogLevel, tag: String, message: Any, throwable: Throwable?) -> Unit = { l, _, m, e ->
|
||||
val args = e ?.let {
|
||||
arrayOf(m, e)
|
||||
|
||||
Reference in New Issue
Block a user