Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions logviewer/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<!--
This file is auto-generated by Vaadin.
If you want to customize the index.html, you can copy this file or create your
own `index.html` in your frontend directory.
By default, the `index.html` file should be in `./frontend/` folder.

NOTE: you need to restart the dev-server after adding the new `index.html` file.
After that, all modifications to `index.html` are recompiled automatically.
-->

<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body, #outlet {
height: 100vh;
width: 100%;
margin: 0;
}
</style>
<!-- index.ts is included here automatically (either by the dev server or during the build) -->
</head>
<body>
<!-- vaadin-router in index.ts needs an outlet for displaying the views -->
<div id="outlet"></div>
</body>
</html>
36 changes: 36 additions & 0 deletions logviewer/frontend/themes/logviewer/main-layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[slot='drawer'] {
background-image: linear-gradient(0deg, var(--lumo-shade-5pct), var(--lumo-shade-5pct));
}

[slot='drawer'] nav a {
text-decoration: none;
transition: color 140ms;
}

[slot='drawer'] nav a .la {
margin-top: calc(var(--lumo-space-xs) * 0.5);
}

[slot='drawer'] nav a::before {
border-radius: var(--lumo-border-radius);
bottom: calc(var(--lumo-space-xs) * 0.5);
content: '';
left: 0;
position: absolute;
right: 0;
top: calc(var(--lumo-space-xs) * 0.5);
transition: background-color 140ms;
}

[slot='drawer'] nav a[highlight] {
color: var(--lumo-primary-text-color);
}

[slot='drawer'] nav a[highlight]::before {
background-color: var(--lumo-primary-color-10pct);
}

[slot='drawer'] footer vaadin-context-menu {
align-items: center;
display: flex;
}
4 changes: 4 additions & 0 deletions logviewer/frontend/themes/logviewer/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Import your application global css files here or add the styles directly to this file */
@import url('./main-layout.css');
@import url('./views/logs-view.css');
@import url('line-awesome/dist/line-awesome/css/line-awesome.min.css');
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lumoImports":["typography","color","spacing","badge","utility"]}
{"lumoImports":["typography","color","spacing","badge","utility"]}
39 changes: 39 additions & 0 deletions logviewer/frontend/themes/logviewer/views/logs-view.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.logs-view {
display: block;
padding: 1em;
}

:root {
--color-info: rgba(120, 107, 213, 0.5);
--color-warn: rgba(170, 187, 97, 0.5);
--color-error: rgba(255, 75, 75, 0.5);
--color-debug: rgba(127, 255, 212, 0.5);
--color-trace: rgba(58, 118, 58, 0.5);
}

p {

line-height: normal;
margin-top: 0.1em;
margin-bottom: 0.1em;
}

.error {
background-color: var(--color-error);
}

.warn {
background-color: var(--color-warn);
}

.info {
background-color: var(--color-info);
}

.debug {
background-color: var(--color-debug);
}

.trace {
background-color: var(--color-trace);
}
36 changes: 0 additions & 36 deletions logviewer/frontend/themes/myapp/main-layout.css

This file was deleted.

3 changes: 0 additions & 3 deletions logviewer/frontend/themes/myapp/styles.css

This file was deleted.

4 changes: 0 additions & 4 deletions logviewer/frontend/themes/myapp/views/hello-world-view.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* And the initial Config at {@link Config}
*/
@SpringBootApplication(exclude = {R2dbcAutoConfiguration.class})
@Theme(value = "myapp")
@Theme(value = "logviewer")
@PWA(name = "LogViewer", shortName = "Logs", offlineResources = {"images/logo.png"})
@NpmPackage(value = "line-awesome", version = "1.3.0")
@Push
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.togetherjava.tjbot.db.generated.tables.pojos.Logevents;

import java.util.Collection;
import java.util.List;

public interface LogRepository {
Expand All @@ -19,4 +20,12 @@ public interface LogRepository {
* @return List of LogEvents
*/
List<Logevents> findAll();

/**
* Fetches all Events, which LogLevel matches the given Collection, from the DB
*
* @return List of LogEvents
*/
List<Logevents> findWithLevelMatching(Collection<String> logLevels);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.togetherjava.tjbot.db.generated.tables.pojos.Logevents;
import org.togetherjava.tjbot.db.generated.tables.records.LogeventsRecord;

import java.util.Collection;
import java.util.List;

import static org.togetherjava.tjbot.db.generated.tables.Logevents.LOGEVENTS;
Expand Down Expand Up @@ -50,6 +51,17 @@ public List<Logevents> findAll() {
});
}


@Override
@SuppressWarnings("java:S1602") // Curly Braces are necessary here
public List<Logevents> findWithLevelMatching(Collection<String> logLevels) {
return this.db.read(ctx -> {
return ctx.selectFrom(LOGEVENTS)
.where(LOGEVENTS.LEVEL.in(logLevels))
.fetch(this::recordToPojo);
});
}

private Logevents recordToPojo(final LogeventsRecord logRecord) {
return new Logevents(logRecord.getId(), logRecord.getTime(), logRecord.getThread(),
logRecord.getLevel(), logRecord.getLoggername(), logRecord.getMessage(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.togetherjava.tjbot.logwatcher.util;

import org.togetherjava.tjbot.db.generated.tables.pojos.Logevents;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;

public final class LogUtils {

/**
* Loglevel of all Configurable Levels in the logger
*/
public enum LogLevel {
INFO,
WARN,
ERROR,
DEBUG,
TRACE;

/**
* Collects all LogLevel in a Set
*
* @return A Set containing every Loglevel
*/
public static Set<LogLevel> getAll() {
return EnumSet.allOf(LogLevel.class);
}

/**
* Maps the LogLevel to their name and collects it in a Set
*
* @return A Set containing every LogLevel as String
*/
public static Set<String> getAllNames() {
return Arrays.stream(values()).map(Enum::name).collect(Collectors.toUnmodifiableSet());
}
}

/**
* Maps a Logevent to the color-coded css-Class (css class has i.e. red as background-color for
* ERROR events)
*
* @param event Logevent from the DB with a specific Logevent
* @return The name of the CSS class to use with this Logevent.
*/
public static String logLevelToCssClass(final Logevents event) {
return event.getLevel().toLowerCase(Locale.ENGLISH);
}



private LogUtils() {}
}
Loading