-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
195 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +0,0 @@ | ||
dependencies { | ||
|
||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
api/common/src/main/kotlin/su/plo/slib/api/logging/McLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package su.plo.slib.api.logging | ||
|
||
/** | ||
* Logger interface for wrapping different loggers. | ||
*/ | ||
interface McLogger { | ||
|
||
/** | ||
* Gets the name of the logger. | ||
*/ | ||
fun getName(): String | ||
|
||
/** | ||
* Log a message at the TRACE level. | ||
* | ||
* @param format The format string. | ||
* @param arguments A list of arguments. | ||
*/ | ||
fun trace(format: String, vararg arguments: Any) | ||
|
||
/** | ||
* Log a message at the DEBUG level. | ||
* | ||
* @param format The format string. | ||
* @param arguments A list of arguments. | ||
*/ | ||
fun debug(format: String, vararg arguments: Any) | ||
|
||
/** | ||
* Log a message at the INFO level. | ||
* | ||
* @param format The format string. | ||
* @param arguments A list of arguments. | ||
*/ | ||
fun info(format: String, vararg arguments: Any) | ||
|
||
/** | ||
* Log a message at the WARN level. | ||
* | ||
* @param format The format string. | ||
* @param arguments A list of arguments. | ||
*/ | ||
fun warn(format: String, vararg arguments: Any) | ||
|
||
/** | ||
* Log a message at the ERROR level. | ||
* | ||
* @param format The format string. | ||
* @param arguments A list of arguments. | ||
*/ | ||
fun error(format: String, vararg arguments: Any) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package su.plo.slib.logging | ||
|
||
import su.plo.slib.api.logging.McLogger | ||
import java.util.logging.Level | ||
import java.util.logging.Logger | ||
|
||
class JavaLogger( | ||
name: String | ||
) : Logger(name, null), McLogger { | ||
|
||
override fun trace(format: String, vararg arguments: Any) { | ||
log(Level.FINEST, String.format(format, *arguments)) | ||
} | ||
|
||
override fun debug(format: String, vararg arguments: Any) { | ||
log(Level.ALL, String.format(format, *arguments)) | ||
} | ||
|
||
override fun info(format: String, vararg arguments: Any) { | ||
log(Level.INFO, String.format(format, *arguments)) | ||
} | ||
|
||
override fun warn(format: String, vararg arguments: Any) { | ||
log(Level.WARNING, String.format(format, *arguments)) | ||
} | ||
|
||
override fun error(format: String, vararg arguments: Any) { | ||
log(Level.SEVERE, String.format(format, *arguments)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package su.plo.slib.logging | ||
|
||
import org.slf4j.Logger | ||
import org.slf4j.LoggerFactory | ||
import su.plo.slib.api.logging.McLogger | ||
|
||
class Slf4jLogger(name: String) : McLogger { | ||
|
||
val logger: Logger = LoggerFactory.getLogger(name) | ||
|
||
override fun getName(): String = | ||
logger.name | ||
|
||
override fun trace(format: String, vararg arguments: Any) { | ||
logger.trace(format, *arguments) | ||
} | ||
|
||
override fun debug(format: String, vararg arguments: Any) { | ||
logger.debug(format, *arguments) | ||
} | ||
|
||
override fun info(format: String, vararg arguments: Any) { | ||
logger.info(format, *arguments) | ||
} | ||
|
||
override fun warn(format: String, vararg arguments: Any) { | ||
logger.warn(format, *arguments) | ||
} | ||
|
||
override fun error(format: String, vararg arguments: Any) { | ||
logger.error(format, *arguments) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
versions/src/main/kotlin/su/plo/slib/mod/logging/Log4jLogger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package su.plo.slib.mod.logging | ||
|
||
import org.apache.logging.log4j.LogManager | ||
import su.plo.slib.api.logging.McLogger | ||
|
||
class Log4jLogger( | ||
name: String | ||
) : McLogger { | ||
|
||
val logger = LogManager.getLogger(name) | ||
|
||
override fun getName(): String = | ||
logger.name | ||
|
||
override fun trace(format: String, vararg arguments: Any) { | ||
logger.trace(format, *arguments) | ||
} | ||
|
||
override fun debug(format: String, vararg arguments: Any) { | ||
logger.debug(format, *arguments) | ||
} | ||
|
||
override fun info(format: String, vararg arguments: Any) { | ||
logger.info(format, *arguments) | ||
} | ||
|
||
override fun warn(format: String, vararg arguments: Any) { | ||
logger.warn(format, *arguments) | ||
} | ||
|
||
override fun error(format: String, vararg arguments: Any) { | ||
logger.error(format, *arguments) | ||
} | ||
} |