com/hypixel/hytale/logger/HytaleLogger.java
package com.hypixel.hytale.logger;
import com.google.common.flogger.AbstractLogger;
import com.google.common.flogger.LogContext;
import com.google.common.flogger.LoggingApi;
import com.google.common.flogger.backend.Platform;
import com.google.common.flogger.parser.DefaultPrintfMessageParser;
import com.google.common.flogger.parser.MessageParser;
import com.hypixel.hytale.logger.backend.HytaleConsole;
import com.hypixel.hytale.logger.backend.HytaleFileHandler;
import com.hypixel.hytale.logger.backend.HytaleLogManager;
import com.hypixel.hytale.logger.backend.HytaleLoggerBackend;
import com.hypixel.hytale.logger.backend.HytaleUncaughtExceptionHandler;
import com.hypixel.hytale.logger.util.LoggerPrintStream;
import io.sentry.IScopes;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.LogManager;
import javax.annotation.Nonnull;
public class HytaleLogger extends AbstractLogger<Api> {
private static final Map<String, HytaleLogger> CACHE;
private static final HytaleLogger LOGGER;
static final NoOp NO_OP;
@Nonnull
private final HytaleLoggerBackend backend;
public static void init() {
HytaleFileHandler fileHandler = HytaleFileHandler.INSTANCE;
HytaleConsole console = HytaleConsole.INSTANCE;
LOGGER.at(Level.INFO).log("Logger Initialized");
}
public static void replaceStd() {
if (!HytaleLoggerBackend.isJunitTest()) {
System.setOut(new LoggerPrintStream(get("SOUT"), Level.INFO));
System.setErr(new LoggerPrintStream(get("SERR"), Level.SEVERE));
}
}
public static HytaleLogger getLogger() {
return LOGGER;
}
@Nonnull
public static HytaleLogger forEnclosingClass() {
String className = Platform.getCallerFinder().findLoggingClass(HytaleLogger.class);
String loggerName = classToLoggerName(className);
return get(loggerName);
}
@Nonnull
public static HytaleLogger forEnclosingClassFull() {
String loggingClass = Platform.getCallerFinder().findLoggingClass(HytaleLogger.class);
return get(loggingClass);
}
@Nonnull
public static HytaleLogger get(String loggerName) {
return (HytaleLogger)CACHE.computeIfAbsent(loggerName, (key) -> new HytaleLogger(HytaleLoggerBackend.getLogger(key)));
}
private HytaleLogger(@Nonnull HytaleLoggerBackend backend) {
super(backend);
this.backend = backend;
}
public Api at(@Nonnull Level level) {
return (Api)(this.isLoggable(level) ? new Context(level) : NO_OP);
}
public String getName() {
return super.getName();
}
@Nonnull
public Level getLevel() {
return this.backend.getLevel();
}
public void setLevel(@Nonnull Level level) {
this.backend.setLevel(level);
}
@Nonnull
public HytaleLogger getSubLogger(String name) {
return new HytaleLogger(this.backend.getSubLogger(name));
}
public void setSentryClient(@Nonnull IScopes scope) {
this.backend.setSentryClient(scope);
}
public void setPropagatesSentryToParent(boolean propagate) {
this.backend.setPropagatesSentryToParent(propagate);
}
@Nonnull
private static String classToLoggerName(@Nonnull String className) {
int lastIndexOf = className.lastIndexOf(46);
String loggerName;
if (lastIndexOf >= 0 && className.length() > lastIndexOf + 1) {
loggerName = className.substring(lastIndexOf + 1);
} else {
loggerName = className;
}
return loggerName;
}
static {
System.setProperty("java.util.logging.manager", HytaleLogManager.class.getName());
HytaleUncaughtExceptionHandler.setup();
LogManager logManager = LogManager.getLogManager();
if (!logManager.getClass().getName().equals(HytaleLogManager.class.getName())) {
throw new IllegalStateException("Log manager wasn't set! Please ensure HytaleLogger is the first logger to be initialized or\nuse `System.setProperty(\"java.util.logging.manager\", HytaleLogManager.class.getName());` at the start of your application.\nLog manager is: " + String.valueOf(logManager));
} else {
CACHE = new ConcurrentHashMap();
LOGGER = new HytaleLogger(HytaleLoggerBackend.getLogger());
NO_OP = new NoOp();
}
}
private static final class NoOp extends LoggingApi.NoOp<Api> implements Api {
private NoOp() {
}
}
final class Context extends LogContext<HytaleLogger, Api> implements Api {
private Context(@Nonnull Level level) {
super(level, false);
}
@Nonnull
protected HytaleLogger getLogger() {
return HytaleLogger.this;
}
@Nonnull
protected Api api() {
return this;
}
@Nonnull
protected Api noOp() {
return HytaleLogger.NO_OP;
}
protected MessageParser getMessageParser() {
return DefaultPrintfMessageParser.getInstance();
}
}
public interface Api extends LoggingApi<Api> {
}
}
com/hypixel/hytale/logger/backend/HytaleConsole.java
package com.hypixel.hytale.logger.backend;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class HytaleConsole extends Thread {
public static final String TYPE_DUMB = "dumb";
public static final HytaleConsole INSTANCE = new HytaleConsole();
private final BlockingQueue<LogRecord> logRecords = new LinkedBlockingQueue();
private final HytaleLogFormatter formatter = new HytaleLogFormatter(this::shouldPrintAnsi);
@Nullable
OutputStreamWriter soutwriter;
OutputStreamWriter serrwriter;
String terminalType;
{
();
.soutwriter = (HytaleLoggerBackend.REAL_SOUT, StandardCharsets.UTF_8);
.serrwriter = (HytaleLoggerBackend.REAL_SERR, StandardCharsets.UTF_8);
.terminalType = ;
.setDaemon();
.start();
}
{
(!.isAlive()) {
.publish0(logRecord);
} {
.logRecords.offer(logRecord);
}
}
{
{
(!.isInterrupted()) {
.publish0((LogRecord).logRecords.take());
}
} (InterruptedException var2) {
Thread.currentThread().interrupt();
}
}
{
.interrupt();
{
.join();
} (InterruptedException var5) {
Thread.currentThread().interrupt();
}
List<LogRecord> list = <LogRecord>();
.logRecords.drainTo(list);
list.forEach(::publish0);
(.soutwriter != ) {
{
.soutwriter.flush();
} (Exception var4) {
}
.soutwriter = ;
}
(.serrwriter != ) {
{
.serrwriter.flush();
} (Exception var3) {
}
.serrwriter = ;
}
}
{
String msg;
{
msg = .formatter.format(record);
} (Exception ex) {
(.serrwriter != ) {
ex.printStackTrace( (.serrwriter));
} {
ex.printStackTrace(System.err);
}
;
}
{
(record.getLevel().intValue() >= Level.SEVERE.intValue()) {
(.serrwriter != ) {
.serrwriter.write(msg);
{
.serrwriter.flush();
} (Exception var5) {
}
} {
HytaleLoggerBackend.REAL_SERR.print(msg);
}
} (.soutwriter != ) {
.soutwriter.write(msg);
{
.soutwriter.flush();
} (Exception var4) {
}
} {
HytaleLoggerBackend.REAL_SOUT.print(msg);
}
} (Exception var6) {
}
}
{
.terminalType = type;
}
{
!.equals(.terminalType);
}
HytaleLogFormatter {
.formatter;
}
}
com/hypixel/hytale/logger/backend/HytaleFileHandler.java
package com.hypixel.hytale.logger.backend;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class HytaleFileHandler extends Thread {
public static final DateTimeFormatter LOG_FILE_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss");
public static final HytaleFileHandler INSTANCE = new HytaleFileHandler();
private final BlockingQueue<LogRecord> logRecords = new LinkedBlockingQueue();
FileHandler fileHandler;
{
();
.setDaemon();
}
{
(.fileHandler == ) {
();
} {
{
(!.isInterrupted()) {
.fileHandler.publish((LogRecord).logRecords.take());
}
} (InterruptedException var2) {
Thread.currentThread().interrupt();
}
}
}
FileHandler {
.fileHandler;
}
{
(.fileHandler != ) {
();
} {
{
Paths.get();
(!Files.isDirectory(logsDirectory, [])) {
Files.createDirectory(logsDirectory);
}
LOG_FILE_DATE_FORMAT;
+ var10000.format(LocalDateTime.now());
fileNamePart + ;
(Files.exists(Paths.get(fileName), [])) {
fileName = fileNamePart + ;
}
.fileHandler = (fileName);
.fileHandler.setEncoding();
.fileHandler.setLevel(Level.ALL);
.fileHandler.setFormatter( (() -> ));
} (IOException e) {
(, e);
}
.start();
}
}
{
(!.isAlive()) {
(.fileHandler != ) {
.fileHandler.publish(logRecord);
}
} {
.logRecords.add(logRecord);
}
}
{
(.fileHandler != ) {
.interrupt();
{
.join();
} (InterruptedException var2) {
Thread.currentThread().interrupt();
}
List<LogRecord> list = <LogRecord>();
.logRecords.drainTo(list);
.fileHandler;
Objects.requireNonNull(var10001);
list.forEach(var10001::publish);
.fileHandler.flush();
.fileHandler.close();
.fileHandler = ;
}
}
}
package com.hypixel.hytale.logger.backend;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.function.BooleanSupplier;
import java.util.logging.Formatter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
public class HytaleLogFormatter extends Formatter {
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
private static final Pattern ANSI_CONTROL_CODES = Pattern.compile("\u001b\\[[;\\d]*m");
private BooleanSupplier ansi;
public int maxModuleName;
private int shorterCount;
public HytaleLogFormatter(BooleanSupplier ansi) {
this.ansi = ansi;
}
@Nonnull
public String format( LogRecord record) {
record.getMessage();
(message == ) {
message = ;
}
(record.getParameters() != && record.getParameters().length > ) {
{
message = String.format(message, record.getParameters());
} (RuntimeException e) {
( + record.getMessage(), e);
}
}
(record.getThrown() != ) {
();
record.getThrown().printStackTrace( (writer));
message = message + + writer.toString();
}
.ansi.getAsBoolean();
(ansi) {
message = message + ;
}
( HytaleLoggerBackend.RawLogRecord) {
!ansi ? stripAnsi(message) + : message + ;
} {
record.getLoggerName();
loggerName.length() + ;
((moduleNameTextSize <= .maxModuleName || moduleNameTextSize >= ) && .shorterCount <= ) {
(moduleNameTextSize < .maxModuleName) {
++.shorterCount;
}
} {
.maxModuleName = moduleNameTextSize;
.shorterCount = ;
}
( + .maxModuleName + message.length());
(ansi) {
;
record.getLevel().intValue();
(level <= Level.ALL.intValue()) {
color = ;
} (level <= Level.FINEST.intValue()) {
color = ;
} (level <= Level.FINER.intValue()) {
color = ;
} (level <= Level.FINE.intValue()) {
color = ;
} (level <= Level.CONFIG.intValue()) {
color = ;
} (level <= Level.INFO.intValue()) {
color = ;
} (level <= Level.WARNING.intValue()) {
color = ;
} (level <= Level.SEVERE.intValue()) {
color = ;
}
(color != ) {
sb.append(color);
}
}
sb.append();
DATE_FORMATTER.formatTo(LocalDateTime.ofInstant(record.getInstant(), ZoneOffset.UTC), sb);
sb.append();
String level;
(Level.WARNING.equals(record.getLevel())) {
level = ;
} {
level = record.getLevel().getName();
}
level.length();
(levelLength < ) {
sb.append(.repeat( - levelLength));
sb.append(level);
} {
sb.append(level, , );
}
sb.append();
sb.append(.repeat(Math.max(, .maxModuleName - moduleNameTextSize)));
sb.append().append(loggerName).append().append(ansi ? message : stripAnsi(message)).append();
sb.toString();
}
}
String {
ANSI_CONTROL_CODES.matcher(message).replaceAll();
}
}
com/hypixel/hytale/logger/backend/HytaleLogManager.java
package com.hypixel.hytale.logger.backend;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
public class HytaleLogManager extends LogManager {
public static HytaleLogManager instance;
public HytaleLogManager() {
instance = this;
this.getLogger("Hytale");
}
public void reset() {
}
private void reset0() {
super.reset();
}
@Nonnull
public Logger getLogger(@Nonnull String name) {
Logger logger = super.getLogger(name);
return (Logger)(logger != null ? logger : new HytaleJdkLogger(HytaleLoggerBackend.getLogger(name)));
}
public static void resetFinally() {
HytaleConsole.INSTANCE.shutdown();
HytaleFileHandler.INSTANCE.shutdown();
(instance != ) {
instance.reset0();
}
}
{
HytaleLoggerBackend backend;
{
(backend.getLoggerName(), (String));
.backend = backend;
}
String {
.backend.getLoggerName();
}
Level {
.backend.getLevel();
}
{
.backend.isLoggable(level);
}
{
.backend.log(record);
}
{
.backend.setLevel(newLevel);
}
}
}
com/hypixel/hytale/logger/backend/HytaleLoggerBackend.java
package com.hypixel.hytale.logger.backend;
import com.google.common.flogger.backend.LogData;
import com.google.common.flogger.backend.LoggerBackend;
import com.google.common.flogger.backend.system.SimpleLogRecord;
import com.hypixel.hytale.logger.sentry.HytaleSentryHandler;
import com.hypixel.hytale.logger.sentry.SkipSentryException;
import io.sentry.IScopes;
import java.io.PrintStream;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.BiConsumer;
import java.util.function.Function;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class HytaleLoggerBackend extends LoggerBackend {
public static Function<String, Level> LOG_LEVEL_LOADER;
public static final PrintStream REAL_SOUT;
public static final PrintStream REAL_SERR;
private static final Map<String, HytaleLoggerBackend> CACHE;
private static final HytaleLoggerBackend ROOT_LOGGER;
OFF_VALUE;
String name;
HytaleLoggerBackend parent;
Level level;
BiConsumer<Level, Level> onLevelChange;
HytaleSentryHandler sentryHandler;
propagateSentryToParent;
CopyOnWriteArrayList<CopyOnWriteArrayList<LogRecord>> subscribers;
{
.level = Level.INFO;
.propagateSentryToParent = ;
.subscribers = ();
.name = name;
.parent = ROOT_LOGGER;
}
{
.level = Level.INFO;
.propagateSentryToParent = ;
.subscribers = ();
.name = name;
.parent = parent;
}
String {
.name;
}
Level {
.level;
}
{
.level.intValue();
lvl.intValue() >= levelValue && levelValue != OFF_VALUE;
}
{
.log((LogRecord)SimpleLogRecord.create(data));
}
{
.log((LogRecord)SimpleLogRecord.error(error, badData));
}
{
.log(logRecord, );
}
{
(.sentryHandler != && !sentryHandled && logRecord.getThrown() != && !SkipSentryException.hasSkipSentry(logRecord.getThrown())) {
.sentryHandler.publish(logRecord);
sentryHandled = ;
}
(!.propagateSentryToParent && !sentryHandled && logRecord.getThrown() != ) {
sentryHandled = ;
}
(.parent != ) {
.parent.log(logRecord, sentryHandled);
} {
HytaleFileHandler.INSTANCE.log(logRecord);
HytaleConsole.INSTANCE.publish(logRecord);
( ; i < .subscribers.size(); ++i) {
((CopyOnWriteArrayList).subscribers.get(i)).add(logRecord);
}
}
}
{
(!ROOT_LOGGER.subscribers.contains(subscriber)) {
ROOT_LOGGER.subscribers.add(subscriber);
}
}
{
(ROOT_LOGGER.subscribers.contains(subscriber)) {
ROOT_LOGGER.subscribers.remove(subscriber);
}
}
HytaleLoggerBackend {
(.name + + name, );
hytaleLoggerBackend.loadLogLevel();
hytaleLoggerBackend;
}
{
(scope != ) {
.sentryHandler = (scope);
.sentryHandler.setLevel(Level.ALL);
} {
.sentryHandler = ;
}
}
{
.propagateSentryToParent = propagate;
}
{
.onLevelChange = onLevelChange;
}
{
.level;
.level = newLevel;
(.onLevelChange != && !Objects.equals(old, newLevel)) {
.onLevelChange.accept(old, newLevel);
}
}
{
(.name != && LOG_LEVEL_LOADER != ) {
(Level)LOG_LEVEL_LOADER.apply(.name);
(level != ) {
.setLevel(level);
}
}
}
{
(Map.Entry<String, Level> e : list) {
getLogger((String)e.getKey()).setLevel((Level)e.getValue());
}
}
{
CACHE.values().forEach(HytaleLoggerBackend::loadLogLevel);
}
HytaleLoggerBackend {
ROOT_LOGGER;
}
HytaleLoggerBackend {
(name.isEmpty()) {
getLogger();
} {
(HytaleLoggerBackend)CACHE.computeIfAbsent(name, HytaleLoggerBackend::);
logger.loadLogLevel();
logger;
}
}
HytaleLoggerBackend {
(HytaleLoggerBackend)CACHE.computeIfAbsent(name, HytaleLoggerBackend::);
logger.setOnLevelChange(onLevelChange);
logger.loadLogLevel();
logger;
}
{
HytaleConsole.INSTANCE.getFormatter().maxModuleName = indent;
HytaleFileHandler.INSTANCE.getFileHandler();
(fileHandler != ) {
((HytaleLogFormatter)fileHandler.getFormatter()).maxModuleName = indent;
}
}
{
(StackTraceElement element : Thread.currentThread().getStackTrace()) {
(element.getClassName().startsWith()) {
;
}
}
;
}
{
ROOT_LOGGER.log((LogRecord)( (Level.ALL, message)));
}
{
REAL_SOUT = System.out;
REAL_SERR = System.err;
CACHE = ();
ROOT_LOGGER = (, (HytaleLoggerBackend));
OFF_VALUE = Level.OFF.intValue();
}
{
{
(level, msg);
}
}
}
com/hypixel/hytale/logger/backend/HytaleUncaughtExceptionHandler.java
package com.hypixel.hytale.logger.backend;
import com.hypixel.hytale.logger.HytaleLogger;
import java.util.logging.Level;
public class HytaleUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
public static final HytaleUncaughtExceptionHandler INSTANCE = new HytaleUncaughtExceptionHandler();
public HytaleUncaughtExceptionHandler() {
}
public static void setup() {
Thread.setDefaultUncaughtExceptionHandler(INSTANCE);
System.setProperty("java.util.concurrent.ForkJoinPool.common.exceptionHandler", HytaleUncaughtExceptionHandler.class.getName());
}
public void uncaughtException(Thread t, Throwable e) {
((HytaleLogger.Api)HytaleLogger.getLogger().at(Level.SEVERE).withCause(e)).log("Exception in thread: %s", t);
}
}
com/hypixel/hytale/logger/sentry/HytaleSentryHandler.java
package com.hypixel.hytale.logger.sentry;
import io.sentry.Breadcrumb;
import io.sentry.Hint;
import io.sentry.IScopes;
import io.sentry.ScopesAdapter;
import io.sentry.Sentry;
import io.sentry.SentryAttribute;
import io.sentry.SentryAttributes;
import io.sentry.SentryEvent;
import io.sentry.SentryIntegrationPackageStorage;
import io.sentry.SentryLevel;
import io.sentry.SentryLogLevel;
import io.sentry.exception.ExceptionMechanismException;
import io.sentry.logger.SentryLogParameters;
import io.sentry.protocol.Mechanism;
import io.sentry.protocol.Message;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Filter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class HytaleSentryHandler extends Handler {
public static final String MECHANISM_TYPE = "JulSentryHandler";
public static ;
IScopes scope;
printfStyle;
Level minimumBreadcrumbLevel;
Level minimumEventLevel;
Level minimumLevel;
{
(scope, );
}
HytaleSentryHandler( IScopes scope, configureFromLogManager) {
.minimumBreadcrumbLevel = Level.INFO;
.minimumEventLevel = Level.SEVERE;
.minimumLevel = Level.INFO;
.setFilter( ());
(configureFromLogManager) {
.retrieveProperties();
}
.scope = scope;
}
{
(.isLoggable(record)) {
{
(ScopesAdapter.getInstance().getOptions().getLogs().isEnabled() && record.getLevel().intValue() >= .minimumLevel.intValue()) {
.captureLog(record);
}
(record.getLevel().intValue() >= .minimumEventLevel.intValue()) {
();
hint.set(, record);
.scope.captureEvent(.createEvent(record), hint);
}
(record.getLevel().intValue() >= .minimumBreadcrumbLevel.intValue()) {
();
hint.set(, record);
Sentry.addBreadcrumb(.createBreadcrumb(record), hint);
}
} (RuntimeException e) {
.reportError(, e, );
}
}
}
{
toSentryLogLevel(loggingEvent.getLevel());
Object[] arguments = loggingEvent.getParameters();
SentryAttributes.of();
loggingEvent.getMessage();
(loggingEvent.getResourceBundle() != && loggingEvent.getResourceBundle().containsKey(loggingEvent.getMessage())) {
message = loggingEvent.getResourceBundle().getString(loggingEvent.getMessage());
}
.maybeFormatted(arguments, message);
(!formattedMessage.equals(message)) {
attributes.add(SentryAttribute.stringAttribute(, message));
}
SentryLogParameters.create(attributes);
params.setOrigin();
Sentry.logger().log(sentryLevel, params, formattedMessage, arguments);
}
String {
(arguments != ) {
{
.formatMessage(message, arguments);
} (RuntimeException var4) {
}
}
message;
}
{
LogManager.getLogManager();
HytaleSentryHandler.class.getName();
.setPrintfStyle(Boolean.parseBoolean(manager.getProperty(className + )));
.setLevel(.parseLevelOrDefault(manager.getProperty(className + )));
manager.getProperty(className + );
(minimumBreadCrumbLevel != ) {
.setMinimumBreadcrumbLevel(.parseLevelOrDefault(minimumBreadCrumbLevel));
}
manager.getProperty(className + );
(minimumEventLevel != ) {
.setMinimumEventLevel(.parseLevelOrDefault(minimumEventLevel));
}
manager.getProperty(className + );
(minimumLevel != ) {
.setMinimumLevel(.parseLevelOrDefault(minimumLevel));
}
}
SentryLevel {
(level.intValue() >= Level.SEVERE.intValue()) {
SentryLevel.ERROR;
} (level.intValue() >= Level.WARNING.intValue()) {
SentryLevel.WARNING;
} (level.intValue() >= Level.INFO.intValue()) {
SentryLevel.INFO;
} {
level.intValue() >= Level.ALL.intValue() ? SentryLevel.DEBUG : ;
}
}
SentryLogLevel {
(level.intValue() >= Level.SEVERE.intValue()) {
SentryLogLevel.ERROR;
} (level.intValue() >= Level.WARNING.intValue()) {
SentryLogLevel.WARN;
} (level.intValue() >= Level.INFO.intValue()) {
SentryLogLevel.INFO;
} {
level.intValue() >= Level.FINE.intValue() ? SentryLogLevel.DEBUG : SentryLogLevel.TRACE;
}
}
Level {
{
Level.parse(levelName.trim());
} (RuntimeException var3) {
Level.WARNING;
}
}
Breadcrumb {
();
breadcrumb.setLevel(formatLevel(record.getLevel()));
breadcrumb.setCategory(record.getLoggerName());
(record.getParameters() != ) {
{
breadcrumb.setMessage(.formatMessage(record.getMessage(), record.getParameters()));
} (RuntimeException var4) {
breadcrumb.setMessage(record.getMessage());
}
} {
breadcrumb.setMessage(record.getMessage());
}
breadcrumb;
}
SentryEvent {
( (record.getMillis()));
event.setLevel(formatLevel(record.getLevel()));
event.setLogger(record.getLoggerName());
();
sentryMessage.setParams(.toParams(record.getParameters()));
record.getMessage();
(record.getResourceBundle() != && record.getResourceBundle().containsKey(record.getMessage())) {
message = record.getResourceBundle().getString(record.getMessage());
}
sentryMessage.setMessage(message);
(record.getParameters() != ) {
{
sentryMessage.setFormatted(.formatMessage(message, record.getParameters()));
} (RuntimeException var8) {
}
}
event.setMessage(sentryMessage);
record.getThrown();
(throwable != ) {
();
mechanism.setType();
(mechanism, throwable, Thread.currentThread());
event.setThrowable(mechanismException);
}
event.setExtra(, String.valueOf(record.getLongThreadID()));
event;
}
List<String> {
List<String> result = ();
(arguments != ) {
(Object argument : arguments) {
(argument != ) {
result.add(argument.toString());
}
}
}
result;
}
String {
String formatted;
(.printfStyle) {
formatted = String.format(message, parameters);
} {
formatted = MessageFormat.format(message, parameters);
}
formatted;
}
{
}
SecurityException {
{
Sentry.close();
} (RuntimeException e) {
.reportError(, e, );
}
}
{
.printfStyle = printfStyle;
}
{
(minimumBreadcrumbLevel != ) {
.minimumBreadcrumbLevel = minimumBreadcrumbLevel;
}
}
Level {
.minimumBreadcrumbLevel;
}
{
(minimumEventLevel != ) {
.minimumEventLevel = minimumEventLevel;
}
}
Level {
.minimumEventLevel;
}
{
(minimumLevel != ) {
.minimumLevel = minimumLevel;
}
}
Level {
.minimumLevel;
}
{
.printfStyle;
}
{
SentryIntegrationPackageStorage.getInstance().addPackage(, );
}
{
{
}
{
record.getLoggerName();
loggerName == || !loggerName.startsWith() || loggerName.startsWith();
}
}
}
com/hypixel/hytale/logger/sentry/SkipSentryException.java
package com.hypixel.hytale.logger.sentry;
public class SkipSentryException extends RuntimeException {
public SkipSentryException() {
}
public SkipSentryException(Throwable cause) {
super(cause);
}
public SkipSentryException(String message, Throwable cause) {
super(message, cause);
}
public static boolean hasSkipSentry(Throwable thrown) {
for(Throwable throwable = thrown; throwable != null; throwable = throwable.getCause()) {
if (throwable instanceof SkipSentryException) {
return true;
}
if (throwable.getCause() == throwable) {
return false;
}
}
return false;
}
}
com/hypixel/hytale/logger/util/GithubMessageUtil.java
package com.hypixel.hytale.logger.util;
import javax.annotation.Nonnull;
public class GithubMessageUtil {
private static final String CI = System.getenv("CI");
public GithubMessageUtil() {
}
public static boolean isGithub() {
return CI != null;
}
@Nonnull
public static String messageError(@Nonnull String file, int line, int column, @Nonnull String message) {
return "::error file=%s,line=%d,col=%d::%s\n".formatted(file, line, column, message.replace("\n", "%0A"));
}
@Nonnull
public static String messageError(@Nonnull String file, @Nonnull String message) {
return "::error file=%s::%s\n".formatted(file, message.replace("\n", "%0A"));
}
@Nonnull
public String {
.formatted(file, line, column, message.replace(, ));
}
String {
.formatted(file, message.replace(, ));
}
}
com/hypixel/hytale/logger/util/LoggerPrintStream.java
package com.hypixel.hytale.logger.util;
import com.hypixel.hytale.logger.HytaleLogger;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.logging.Level;
public class LoggerPrintStream extends PrintStream {
private final HytaleLogger logger;
private final Level level;
private final ByteArrayOutputStream bufferedOutput;
private int last;
public LoggerPrintStream(HytaleLogger logger, Level level) {
super(new ByteArrayOutputStream());
this.logger = logger;
this.level = level;
this.bufferedOutput = (ByteArrayOutputStream)super.out;
this.last = -1;
}
public void write(int b) {
if (this.last == 13 && b == 10) {
this.last = -1;
} else {
if (b != 10 && b != 13) {
super.write(b);
} {
{
.logger.at(.level).log(.bufferedOutput.toString());
} {
.bufferedOutput.reset();
}
}
.last = b;
}
}
{
(len < ) {
(len);
} {
( ; i < len; ++i) {
.write(buf[off + i]);
}
}
}
HytaleLogger {
.logger;
}
Level {
.level;
}
}