
com.sshtools.slf4jtty.TtyConfigurationSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of slf4j-tty Show documentation
Show all versions of slf4j-tty Show documentation
An SLF4J log provider that directly implements the SLF4J API
and provides logging output suitable for console output (i.e. not to a
file).
The width of the output is restricted to the terminal width, with the
possibility to split the width into multiple sections, each which may be
a fixed width, or 'auto' which divides all remaining space amongst other
automative sections.
Any log attribute fields may then be placed in any of the sections with
a particular alignment. Text will not overflow out of its section.
Sections may be colour or styled with other text attributes, including
hyperlinks for supported termins.
Emoticons and other graphical sequences may be used in place of log
levels.
Configuration is achieved via 'ini' type files, which are reload
automatically when changed.
The newest version!
package com.sshtools.slf4jtty;
import java.util.function.Supplier;
import org.jline.terminal.Terminal;
import com.sshtools.jini.config.INISet;
import com.sshtools.jini.config.Monitor;
import uk.co.bithatch.nativeimage.annotations.Resource;
@Resource({"com/sshtools/slf4jtty/TtyConfiguration\\.schema\\.ini"})
public final class TtyConfigurationSet {
private final static class Default {
private static TtyConfigurationSet DEFAULT = new TtyConfigurationSet();
}
public static TtyConfigurationSet get() {
return Default.DEFAULT;
}
public enum DateTimeType {
DATE, TIME, DATE_TIME
}
private final INISet.Builder loggersBldr;
private final INISet.Builder bldr;
private Supplier terminalFactory;
private TtyLoggerConfiguration configuration;
TtyConfigurationSet() {
var mtr = new Monitor();
bldr = new INISet.Builder("output").
withApp("slf4j-tty").
withSchema(TtyConfigurationSet.class, "TtyConfiguration.schema.ini").
withOptionalDefault(TtyConfigurationSet.class, "/slf4j-tty.ini").
withMonitor(mtr);
loggersBldr = new INISet.Builder("loggers").
withApp("slf4j-tty").
withOptionalDefault(TtyConfigurationSet.class, "/slf4j-tty-loggers.ini").
withMonitor(mtr);
}
public void terminalFactory(Supplier terminalFactory) {
if(configuration!= null) {
throw new IllegalStateException("Cannot get after configuration has been built.");
}
this.terminalFactory = terminalFactory;
}
public INISet.Builder configurationBuilder() {
if(configuration != null)
throw new IllegalStateException("Cannot get after configuration has been built.");
return bldr;
}
public INISet.Builder loggersBuilder() {
if(configuration != null)
throw new IllegalStateException("Cannot get after configuration has been built.");
return loggersBldr;
}
TtyLoggerConfiguration build() {
if(configuration != null)
throw new IllegalStateException("Already build.");
return configuration = new TtyLoggerConfiguration(bldr.build(), loggersBldr.build(), terminalFactory);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy