src/main/kotlin/de/uapcore/lightpit/MyLogger.kt

Sun, 28 Jul 2024 12:19:42 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 28 Jul 2024 12:19:42 +0200
changeset 303
4c5342255263
parent 247
e71ae69c68c0
permissions
-rw-r--r--

add changelog entry for issue #401

247
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
1 /*
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
2 * Copyright 2021 Mike Becker. All rights reserved.
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
3 *
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
4 * Redistribution and use in source and binary forms, with or without
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
5 * modification, are permitted provided that the following conditions are met:
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
6 *
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
7 * 1. Redistributions of source code must retain the above copyright
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
8 * notice, this list of conditions and the following disclaimer.
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
9 *
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
12 * documentation and/or other materials provided with the distribution.
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
13 *
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
24 */
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
25
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
26 package de.uapcore.lightpit
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28 import java.util.logging.Level
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 import java.util.logging.Logger
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 class MyLogger {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 private val logger: Logger = Logger.getLogger("de.uapcore.lightpit.Logger")
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 fun info(fmt: String, vararg args: Any?) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35 logger.log(Level.INFO, fmt, args)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 fun debug(fmt: String, vararg args: Any?) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 logger.log(Level.FINE, fmt, args)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 fun warn(fmt: String, vararg args: Any?) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 logger.log(Level.WARNING, fmt, args)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43 fun error(fmt: String, vararg args: Any?) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 logger.log(Level.SEVERE, fmt, args)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46 fun trace(fmt: String, vararg args: Any?) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 logger.log(Level.FINEST, fmt, args)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 fun info(msg: String, ex: Throwable) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 logger.log(Level.INFO, msg, ex)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 fun debug(msg: String, ex: Throwable) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 logger.log(Level.FINE, msg, ex)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 fun warn(msg: String, ex: Throwable) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 logger.log(Level.WARNING, msg, ex)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 fun error(msg: String, ex: Throwable) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 logger.log(Level.SEVERE, msg, ex)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 fun trace(msg: String, ex: Throwable) {
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 logger.log(Level.FINEST, msg, ex)
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 }
e71ae69c68c0 remove log4j entirely
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 }

mercurial