improved color logger
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -4,6 +4,7 @@ package de.srsoftware.logging;
|
|||||||
import static de.srsoftware.logging.ConsoleColors.*;
|
import static de.srsoftware.logging.ConsoleColors.*;
|
||||||
import static java.lang.System.Logger.Level.*;
|
import static java.lang.System.Logger.Level.*;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -12,6 +13,9 @@ import java.util.ResourceBundle;
|
|||||||
public class ColorLogger implements System.Logger {
|
public class ColorLogger implements System.Logger {
|
||||||
private final String name;
|
private final String name;
|
||||||
private static int rootLevel = INFO.getSeverity();
|
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) {
|
public ColorLogger(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -50,7 +54,12 @@ public class ColorLogger implements System.Logger {
|
|||||||
private static String colorize(String message, int severity) {
|
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 color = severity >= ERROR.getSeverity() ? RED : severity >= WARNING.getSeverity() ? YELLOW : severity >= INFO.getSeverity() ? WHITE_BRIGHT : WHITE;
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
|
var day =DATE.format(date);
|
||||||
return WHITE + FORMAT.format(date) + " " + color + message + RESET;
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,35 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Light OIDC</title>
|
<title>Light OIDC</title>
|
||||||
<script src="common.js"></script>
|
<script src="common.js"></script>
|
||||||
<script src="user.js"></script>
|
<script src="user.js"></script>
|
||||||
<script src="clients.js"></script>
|
<script src="clients.js"></script>
|
||||||
<link rel="stylesheet" href="style.css" />
|
<link rel="stylesheet" href="style.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<nav></nav>
|
||||||
<a id="clients" href="clients.html">Clients</a>
|
<h1>Clients</h1>
|
||||||
</nav>
|
|
||||||
<h1>Clients</h1>
|
<fieldset>
|
||||||
<fieldset>
|
<legend>bei LightOIDC registrierte Clients:</legend>
|
||||||
<legend>bei LightOIDC registrierte Clients:</legend>
|
<table>
|
||||||
<table>
|
<tr>
|
||||||
<tr>
|
<th>Client</th>
|
||||||
<th>Client</th>
|
<th>ID</th>
|
||||||
<th>ID</th>
|
<th>Weiterleitungs-URLs</th>
|
||||||
<th>Weiterleitungs-URLs</th>
|
<th>Aktionen</th>
|
||||||
<th>Aktionen</th>
|
</tr>
|
||||||
</tr>
|
<tr id="bottom">
|
||||||
<tr id="bottom">
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td>
|
||||||
<td>
|
<button onclick="window.location.href='newclient.html';">Neuen Client hinzufügen…</button>
|
||||||
<button onclick="window.location.href='newclient.html';">Neuen Client hinzufügen…</button>
|
</td>
|
||||||
</td>
|
</tr>
|
||||||
</tr>
|
</table>
|
||||||
</table>
|
<span class="hidden" id="message">Client "{}" wirklich löschen?</span>
|
||||||
<span class="hidden" id="message">Client "{}" wirklich löschen?</span>
|
</fieldset>
|
||||||
</fieldset>
|
</body>
|
||||||
</body>
|
</html>
|
||||||
</html>
|
|
||||||
|
|||||||
@@ -1,38 +1,36 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Light OIDC</title>
|
<title>Light OIDC</title>
|
||||||
<script src="common.js"></script>
|
<script src="common.js"></script>
|
||||||
<script src="user.js"></script>
|
<script src="user.js"></script>
|
||||||
<script src="clients.js"></script>
|
<script src="clients.js"></script>
|
||||||
<link rel="stylesheet" href="style.css" />
|
<link rel="stylesheet" href="style.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<nav></nav>
|
||||||
<a id="clients" href="clients.html">Clients</a>
|
<h1>Clients</h1>
|
||||||
</nav>
|
|
||||||
<h1>Clients</h1>
|
|
||||||
<a href="https://umbrella.srsoftware.de/user/login">Umbrella</a>
|
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>These are clients that are registered with LightOIDC:</legend>
|
<legend>These are clients that are registered with LightOIDC:</legend>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Client</th>
|
<th>Client</th>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Redirect URLs</th>
|
<th>Redirect URLs</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr id="bottom">
|
<tr id="bottom">
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<button onclick="window.location.href='newclient.html';">Add new client…</button>
|
<button onclick="window.location.href='newclient.html';">Add new client…</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<span class="hidden" id="message">Really remove client "{}"?</span>
|
<span class="hidden" id="message">Really remove client "{}"?</span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</body>
|
<a href="https://umbrella.srsoftware.de/user/login">Umbrella</a>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user