mirror of
https://github.com/yushijinhun/authlib-injector.git
synced 2024-11-15 06:11:09 +01:00
Friendly log messages
This commit is contained in:
parent
d86d99c547
commit
6a25aaeffa
6 changed files with 40 additions and 40 deletions
|
@ -68,17 +68,17 @@ public final class AuthlibInjector {
|
|||
|
||||
public static void bootstrap(Consumer<ClassFileTransformer> transformerRegistry) {
|
||||
if (!booted.compareAndSet(false, true)) {
|
||||
Logging.LAUNCH.info("already booted, skipping");
|
||||
Logging.LAUNCH.info("Already started, skipping");
|
||||
return;
|
||||
}
|
||||
|
||||
Logging.LAUNCH.info("version: " + getVersion());
|
||||
Logging.LAUNCH.info("Version: " + getVersion());
|
||||
|
||||
Optional<YggdrasilConfiguration> optionalConfig = configure();
|
||||
if (optionalConfig.isPresent()) {
|
||||
transformerRegistry.accept(createTransformer(optionalConfig.get()));
|
||||
} else {
|
||||
Logging.LAUNCH.warning("no config available");
|
||||
Logging.LAUNCH.warning("No config available");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public final class AuthlibInjector {
|
|||
if (prefetched == null) {
|
||||
prefetched = System.getProperty(PROP_PREFETCHED_DATA_OLD);
|
||||
if (prefetched != null) {
|
||||
Logging.LAUNCH.warning("org.to2mbn.authlibinjector.config.prefetched option is deprecated and will be removed in a future release.");
|
||||
Logging.LAUNCH.warning(PROP_PREFETCHED_DATA_OLD + " option is deprecated, please use " + PROP_PREFETCHED_DATA + " instead");
|
||||
}
|
||||
}
|
||||
return Optional.ofNullable(prefetched);
|
||||
|
@ -96,44 +96,44 @@ public final class AuthlibInjector {
|
|||
private static Optional<YggdrasilConfiguration> configure() {
|
||||
String apiRoot = System.getProperty(PROP_API_ROOT);
|
||||
if (apiRoot == null) return empty();
|
||||
Logging.CONFIG.info("api root: " + apiRoot);
|
||||
Logging.CONFIG.info("API root: " + apiRoot);
|
||||
|
||||
String metadataResponse;
|
||||
|
||||
Optional<String> prefetched = getPrefetchedResponse();
|
||||
if (!prefetched.isPresent()) {
|
||||
Logging.CONFIG.info("fetching metadata");
|
||||
Logging.CONFIG.info("Fetching metadata");
|
||||
try {
|
||||
metadataResponse = asString(getURL(apiRoot));
|
||||
} catch (IOException e) {
|
||||
Logging.CONFIG.severe("unable to fetch metadata: " + e);
|
||||
Logging.CONFIG.severe("Failed to fetch metadata: " + e);
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
|
||||
} else {
|
||||
Logging.CONFIG.info("prefetched metadata detected");
|
||||
Logging.CONFIG.info("Prefetched metadata detected");
|
||||
try {
|
||||
metadataResponse = new String(Base64.getDecoder().decode(removeNewLines(prefetched.get())), UTF_8);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Logging.CONFIG.severe("unable to decode metadata: " + e + "\n"
|
||||
+ "metadata to decode:\n"
|
||||
Logging.CONFIG.severe("Unable to decode metadata: " + e + "\n"
|
||||
+ "Encoded metadata:\n"
|
||||
+ prefetched.get());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
Logging.CONFIG.fine("metadata: " + metadataResponse);
|
||||
Logging.CONFIG.fine("Metadata: " + metadataResponse);
|
||||
|
||||
YggdrasilConfiguration configuration;
|
||||
try {
|
||||
configuration = YggdrasilConfiguration.parse(apiRoot, metadataResponse);
|
||||
} catch (UncheckedIOException e) {
|
||||
Logging.CONFIG.severe("unable to parse metadata: " + e + "\n"
|
||||
+ "metadata to parse:\n"
|
||||
Logging.CONFIG.severe("Unable to parse metadata: " + e + "\n"
|
||||
+ "Raw metadata:\n"
|
||||
+ metadataResponse);
|
||||
throw e;
|
||||
}
|
||||
Logging.CONFIG.fine("parsed metadata: " + configuration);
|
||||
Logging.CONFIG.fine("Parsed metadata: " + configuration);
|
||||
return of(configuration);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,14 +33,14 @@ public class LocalYggdrasilHandle {
|
|||
if (started)
|
||||
return;
|
||||
if (configuration == null)
|
||||
throw new IllegalStateException("configuration hasn't been set yet");
|
||||
throw new IllegalStateException("Configuration hasn't been set yet");
|
||||
httpd = new LocalYggdrasilHttpd(0, configuration);
|
||||
try {
|
||||
httpd.start();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("httpd failed to start");
|
||||
throw new IllegalStateException("Httpd failed to start");
|
||||
}
|
||||
Logging.HTTPD.info("httpd is running on port " + getLocalApiPort());
|
||||
Logging.HTTPD.info("Httpd is running on port " + getLocalApiPort());
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,25 +61,25 @@ public class LocalYggdrasilHttpd extends NanoHTTPD {
|
|||
.map(encoded -> asString(Base64.getDecoder().decode(encoded)))
|
||||
.flatMap(texturesPayload -> obtainTextureUrl(texturesPayload, "SKIN"));
|
||||
} catch (UncheckedIOException e) {
|
||||
Logging.HTTPD.log(Level.WARNING, "unable to fetch skin for " + username, e);
|
||||
Logging.HTTPD.log(Level.WARNING, "Failed to fetch skin for " + username, e);
|
||||
return of(newFixedLengthResponse(Status.INTERNAL_ERROR, null, null));
|
||||
}
|
||||
|
||||
if (skinUrl.isPresent()) {
|
||||
String url = skinUrl.get();
|
||||
Logging.HTTPD.fine("retrieving skin for " + username + " from " + url);
|
||||
Logging.HTTPD.fine("Retrieving skin for " + username + " from " + url);
|
||||
byte[] data;
|
||||
try {
|
||||
data = getURL(url);
|
||||
} catch (IOException e) {
|
||||
Logging.HTTPD.log(Level.WARNING, "unable to retrieve skin from " + url, e);
|
||||
Logging.HTTPD.log(Level.WARNING, "Failed to retrieve skin from " + url, e);
|
||||
return of(newFixedLengthResponse(Status.INTERNAL_ERROR, null, null));
|
||||
}
|
||||
Logging.HTTPD.info("retrieved skin for " + username + " from " + url + ", " + data.length + " bytes");
|
||||
Logging.HTTPD.info("Retrieved skin for " + username + " from " + url + ", " + data.length + " bytes");
|
||||
return of(newFixedLengthResponse(Status.OK, "image/png", new ByteArrayInputStream(data), data.length));
|
||||
|
||||
} else {
|
||||
Logging.HTTPD.info("no skin found for " + username);
|
||||
Logging.HTTPD.info("No skin is found for " + username);
|
||||
return of(newFixedLengthResponse(Status.NOT_FOUND, null, null));
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class LocalYggdrasilHttpd extends NanoHTTPD {
|
|||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
Logging.HTTPD.fine("query uuid of username " + username + ", response: " + responseText);
|
||||
Logging.HTTPD.fine("Query UUID of username " + username + ", response: " + responseText);
|
||||
|
||||
JSONArray response = asJsonArray(parseJson(responseText));
|
||||
if (response.size() == 0) {
|
||||
|
@ -116,10 +116,10 @@ public class LocalYggdrasilHttpd extends NanoHTTPD {
|
|||
throw new UncheckedIOException(e);
|
||||
}
|
||||
if (responseText.isEmpty()) {
|
||||
Logging.HTTPD.fine("query profile of " + uuid + ", not found");
|
||||
Logging.HTTPD.fine("Query profile of " + uuid + ", not found");
|
||||
return empty();
|
||||
}
|
||||
Logging.HTTPD.fine("query profile of " + uuid + ", response: " + responseText);
|
||||
Logging.HTTPD.fine("Query profile of " + uuid + ", response: " + responseText);
|
||||
|
||||
JSONObject response = asJsonObject(parseJson(responseText));
|
||||
return asJsonArray(response.get("properties")).stream()
|
||||
|
@ -137,7 +137,7 @@ public class LocalYggdrasilHttpd extends NanoHTTPD {
|
|||
.map(JsonUtils::asJsonObject)
|
||||
.map(it -> ofNullable(it.get("url"))
|
||||
.map(JsonUtils::asJsonString)
|
||||
.orElseThrow(() -> newUncheckedIOException("Invalid JSON: missing texture url")));
|
||||
.orElseThrow(() -> newUncheckedIOException("Invalid JSON: Missing texture url")));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,20 +16,20 @@ public class AuthlibInjectorPremain {
|
|||
|
||||
public static void premain(String arg, Instrumentation instrumentation) {
|
||||
try {
|
||||
Logging.LAUNCH.info("launched from premain");
|
||||
Logging.LAUNCH.info("Launched from premain");
|
||||
initInjector(arg, instrumentation, false);
|
||||
} catch (Throwable e) {
|
||||
Logging.LAUNCH.log(Level.SEVERE, "an exception has been caught, exiting", e);
|
||||
Logging.LAUNCH.log(Level.SEVERE, "An exception has occurred, exiting", e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void agentmain(String arg, Instrumentation instrumentation) {
|
||||
try {
|
||||
Logging.LAUNCH.info("launched from agentmain");
|
||||
Logging.LAUNCH.info("Launched from agentmain");
|
||||
initInjector(arg, instrumentation, true);
|
||||
} catch (Throwable e) {
|
||||
Logging.LAUNCH.log(Level.SEVERE, "an exception has been caught", e);
|
||||
Logging.LAUNCH.log(Level.SEVERE, "An exception has occurred", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,10 +42,10 @@ public class AuthlibInjectorPremain {
|
|||
|
||||
if (needsRetransform) {
|
||||
if (retransformSupported) {
|
||||
Logging.TRANSFORM.info("start retransforming");
|
||||
Logging.TRANSFORM.info("Start retransforming");
|
||||
doRetransform(instrumentation);
|
||||
} else {
|
||||
Logging.TRANSFORM.warning("retransforming is not supported");
|
||||
Logging.TRANSFORM.warning("Retransform is not supported");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,9 +64,9 @@ public class AuthlibInjectorPremain {
|
|||
instrumentation.retransformClasses(classToRetransform);
|
||||
}
|
||||
long t1 = System.currentTimeMillis();
|
||||
Logging.TRANSFORM.info("retransforming finished in " + (t1 - t0) + "ms");
|
||||
Logging.TRANSFORM.info("Retransform finished in " + (t1 - t0) + "ms");
|
||||
} catch (Throwable e) {
|
||||
Logging.TRANSFORM.log(Level.SEVERE, "unable to retransform", e);
|
||||
Logging.TRANSFORM.log(Level.SEVERE, "Failed to retransform", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class AuthlibInjectorPremain {
|
|||
}
|
||||
}
|
||||
}
|
||||
Logging.TRANSFORM.fine("loaded " + loadedClasses.length + " classes, " + idx + " to retransform");
|
||||
Logging.TRANSFORM.fine("Loaded " + loadedClasses.length + " classes, " + idx + " to retransform");
|
||||
return Arrays.copyOf(dest, idx);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ClassTransformer implements ClassFileTransformer {
|
|||
ClassReader reader = new ClassReader(classBuffer);
|
||||
reader.accept(optionalVisitor.get(), 0);
|
||||
if (currentModified) {
|
||||
Logging.TRANSFORM.info("transform " + className + " using " + unit);
|
||||
Logging.TRANSFORM.info("Transformed " + className + " with " + unit);
|
||||
modified = true;
|
||||
classBuffer = writer.toByteArray();
|
||||
}
|
||||
|
@ -88,11 +88,11 @@ public class ClassTransformer implements ClassFileTransformer {
|
|||
}
|
||||
return classBuffer;
|
||||
} else {
|
||||
Logging.TRANSFORM.fine("no transform performed on " + className);
|
||||
Logging.TRANSFORM.fine("No transformation is applied to " + className);
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Logging.TRANSFORM.log(Level.WARNING, "unable to transform: " + internalClassName, e);
|
||||
Logging.TRANSFORM.log(Level.WARNING, "Failed to transform " + internalClassName, e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -102,7 +102,7 @@ public class ClassTransformer implements ClassFileTransformer {
|
|||
try {
|
||||
Files.write(Paths.get(className + "_dump.class"), classBuffer, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
Logging.TRANSFORM.log(Level.WARNING, "unable to dump class " + className, e);
|
||||
Logging.TRANSFORM.log(Level.WARNING, "Failed to dump class " + className, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class LdcTransformUnit implements TransformUnit {
|
|||
Optional<String> transformed = ldcMapper.apply((String) cst);
|
||||
if (transformed.isPresent() && !transformed.get().equals(cst)) {
|
||||
modifiedCallback.run();
|
||||
Logging.TRANSFORM.info("transform [" + cst + "] to [" + transformed.get() + "]");
|
||||
Logging.TRANSFORM.info("Transformed string [" + cst + "] to [" + transformed.get() + "]");
|
||||
super.visitLdcInsn(transformed.get());
|
||||
} else {
|
||||
super.visitLdcInsn(cst);
|
||||
|
|
Loading…
Reference in a new issue