Browse Source

improved color logger

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
sqlite
Stephan Richter 4 months ago
parent
commit
493c642992
  1. 13
      de.srsoftware.logging/src/main/java/de/srsoftware/logging/ColorLogger.java
  2. 19
      de.srsoftware.oidc.web/src/main/resources/de/clients.html
  3. 14
      de.srsoftware.oidc.web/src/main/resources/en/clients.html

13
de.srsoftware.logging/src/main/java/de/srsoftware/logging/ColorLogger.java

@ -4,6 +4,7 @@ package de.srsoftware.logging; @@ -4,6 +4,7 @@ package de.srsoftware.logging;
import static de.srsoftware.logging.ConsoleColors.*;
import static java.lang.System.Logger.Level.*;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@ -12,6 +13,9 @@ import java.util.ResourceBundle; @@ -12,6 +13,9 @@ import java.util.ResourceBundle;
public class ColorLogger implements System.Logger {
private final String name;
private static int rootLevel = INFO.getSeverity();
private static DateFormat TIME = new SimpleDateFormat("hh:mm:ss.SSS");
private static DateFormat DATE = new SimpleDateFormat("yyyy-MM-dd");
private static String lastDate = null;
public ColorLogger(String name) {
this.name = name;
@ -50,7 +54,12 @@ public class ColorLogger implements System.Logger { @@ -50,7 +54,12 @@ public class ColorLogger implements System.Logger {
private static String colorize(String message, int severity) {
var color = severity >= ERROR.getSeverity() ? RED : severity >= WARNING.getSeverity() ? YELLOW : severity >= INFO.getSeverity() ? WHITE_BRIGHT : WHITE;
var date = new Date();
var FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
return WHITE + FORMAT.format(date) + " " + color + message + RESET;
var day =DATE.format(date);
StringBuilder sb = new StringBuilder();
if (!day.equals(lastDate)){
lastDate = day;
sb.append(WHITE).append(day).append("\n");
}
return sb.append(WHITE).append(TIME.format(date)).append(" ").append(color).append(message).append(RESET).toString();
}
}

19
de.srsoftware.oidc.web/src/main/resources/de/clients.html

@ -1,18 +1,17 @@ @@ -1,18 +1,17 @@
<html>
<head>
<head>
<meta charset="utf-8">
<title>Light OIDC</title>
<script src="common.js"></script>
<script src="user.js"></script>
<script src="clients.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<nav>
<a id="clients" href="clients.html">Clients</a>
</nav>
<h1>Clients</h1>
<fieldset>
</head>
<body>
<nav></nav>
<h1>Clients</h1>
<fieldset>
<legend>bei LightOIDC registrierte Clients:</legend>
<table>
<tr>
@ -31,6 +30,6 @@ @@ -31,6 +30,6 @@
</tr>
</table>
<span class="hidden" id="message">Client "{}" wirklich löschen?</span>
</fieldset>
</body>
</fieldset>
</body>
</html>

14
de.srsoftware.oidc.web/src/main/resources/en/clients.html

@ -1,18 +1,15 @@ @@ -1,18 +1,15 @@
<html>
<head>
<head>
<meta charset="utf-8">
<title>Light OIDC</title>
<script src="common.js"></script>
<script src="user.js"></script>
<script src="clients.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<nav>
<a id="clients" href="clients.html">Clients</a>
</nav>
</head>
<body>
<nav></nav>
<h1>Clients</h1>
<a href="https://umbrella.srsoftware.de/user/login">Umbrella</a>
<fieldset>
<legend>These are clients that are registered with LightOIDC:</legend>
@ -34,5 +31,6 @@ @@ -34,5 +31,6 @@
</table>
<span class="hidden" id="message">Really remove client "{}"?</span>
</fieldset>
</body>
<a href="https://umbrella.srsoftware.de/user/login">Umbrella</a>
</body>
</html>
Loading…
Cancel
Save