Skip to content

Commit

Permalink
Unify on using LOG over LOGGER (#8288)
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte authored Dec 17, 2024
1 parent 916f77e commit 25a4753
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import appeng.menu.implementations.PatternAccessTermMenu;

public class PatternAccessTermScreen<C extends PatternAccessTermMenu> extends AEBaseScreen<C> {
private static final Logger LOGGER = LoggerFactory.getLogger(PatternAccessTermScreen.class);
private static final Logger LOG = LoggerFactory.getLogger(PatternAccessTermScreen.class);

private static final int GUI_WIDTH = 195;
private static final int GUI_TOP_AND_BOTTOM_PADDING = 54;
Expand Down Expand Up @@ -443,7 +443,7 @@ public void postIncrementalUpdate(long inventoryId,
Int2ObjectMap<ItemStack> slots) {
var record = byId.get(inventoryId);
if (record == null) {
LOGGER.warn("Ignoring incremental update for unknown inventory id {}", inventoryId);
LOG.warn("Ignoring incremental update for unknown inventory id {}", inventoryId);
return;
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/appeng/client/guidebook/Guide.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
* guide-specific subdirectory of resource packs.
*/
public final class Guide implements PageCollection {
private static final Logger LOGGER = LoggerFactory.getLogger(Guide.class);
private static final Logger LOG = LoggerFactory.getLogger(Guide.class);

private final String defaultNamespace;
private final String folder;
Expand Down Expand Up @@ -199,7 +199,7 @@ public static void runDatapackReload() {
@Nullable
public ParsedGuidePage getParsedPage(ResourceLocation id) {
if (pages == null) {
LOGGER.warn("Can't get page {}. Pages not loaded yet.", id);
LOG.warn("Can't get page {}. Pages not loaded yet.", id);
return null;
}

Expand Down Expand Up @@ -233,7 +233,7 @@ public byte[] loadAsset(ResourceLocation id) {
return in.readAllBytes();
} catch (FileNotFoundException ignored) {
} catch (IOException e) {
LOGGER.error("Failed to open guidebook asset {}", path);
LOG.error("Failed to open guidebook asset {}", path);
return null;
}
}
Expand All @@ -248,7 +248,7 @@ public byte[] loadAsset(ResourceLocation id) {
try (var input = resource.open()) {
return input.readAllBytes();
} catch (IOException e) {
LOGGER.error("Failed to open guidebook asset {}", id);
LOG.error("Failed to open guidebook asset {}", id);
return null;
}
}
Expand Down Expand Up @@ -314,7 +314,7 @@ protected Map<ResourceLocation, ParsedGuidePage> prepare(ResourceManager resourc
try (var in = entry.getValue().open()) {
pages.put(pageId, PageCompiler.parse(sourcePackId, pageId, in));
} catch (IOException e) {
LOGGER.error("Failed to load guidebook page {} from pack {}", pageId, sourcePackId, e);
LOG.error("Failed to load guidebook page {} from pack {}", pageId, sourcePackId, e);
}
}

Expand Down Expand Up @@ -445,7 +445,7 @@ private Builder(@Nullable IEventBus modEventBus, String defaultNamespace, String
this.startupPage = ResourceLocation.parse(startupPageIdText);
}
} catch (Exception e) {
LOGGER.error("Specified invalid page id in system property {}", startupPageProperty);
LOG.error("Specified invalid page id in system property {}", startupPageProperty);
}

// Development sources folder
Expand Down Expand Up @@ -640,7 +640,7 @@ private ExtensionCollection buildExtensions() {
private void validateAll() {
// Iterate and compile all pages to warn about errors on startup
for (var entry : developmentPages.entrySet()) {
LOGGER.info("Compiling {}", entry.getKey());
LOG.info("Compiling {}", entry.getKey());
getPage(entry.getKey());
}
}
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/appeng/client/guidebook/GuideSourceWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import appeng.client.guidebook.compiler.ParsedGuidePage;

class GuideSourceWatcher {
private static final Logger LOGGER = LoggerFactory.getLogger(GuideSourceWatcher.class);
private static final Logger LOG = LoggerFactory.getLogger(GuideSourceWatcher.class);

/**
* The {@link ResourceLocation} namespace to use for files in the watched folder.
Expand Down Expand Up @@ -68,7 +68,7 @@ public GuideSourceWatcher(String namespace, Path sourceFolder) {
throw new RuntimeException("Cannot find the specified folder for the AE2 guidebook sources: "
+ sourceFolder);
}
LOGGER.info("Watching guidebook sources in {}", sourceFolder);
LOG.info("Watching guidebook sources in {}", sourceFolder);

watchExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
.setDaemon(true)
Expand All @@ -85,7 +85,7 @@ public GuideSourceWatcher(String namespace, Path sourceFolder) {
.listener(new Listener())
.build();
} catch (IOException e) {
LOGGER.error("Failed to watch for changes in the guidebook sources at {}", sourceFolder, e);
LOG.error("Failed to watch for changes in the guidebook sources at {}", sourceFolder, e);
watcher = null;
}
sourceWatcher = watcher;
Expand Down Expand Up @@ -119,23 +119,23 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {

@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) {
LOGGER.error("Failed to list page {}", file, exc);
LOG.error("Failed to list page {}", file, exc);
return FileVisitResult.CONTINUE;
}

@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
if (exc != null) {
LOGGER.error("Failed to list all pages in {}", dir, exc);
LOG.error("Failed to list all pages in {}", dir, exc);
}
return FileVisitResult.CONTINUE;
}
});
} catch (IOException e) {
LOGGER.error("Failed to list all pages in {}", sourceFolder, e);
LOG.error("Failed to list all pages in {}", sourceFolder, e);
}

LOGGER.info("Loading {} guidebook pages", pagesToLoad.size());
LOG.info("Loading {} guidebook pages", pagesToLoad.size());
var loadedPages = pagesToLoad.entrySet()
.stream()
.map(entry -> {
Expand All @@ -144,14 +144,14 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
return PageCompiler.parse(sourcePackId, entry.getKey(), in);

} catch (Exception e) {
LOGGER.error("Failed to reload guidebook page {}", path, e);
LOG.error("Failed to reload guidebook page {}", path, e);
return null;
}
})
.filter(Objects::nonNull)
.toList();

LOGGER.info("Loaded {} pages from {} in {}", loadedPages.size(), sourceFolder, stopwatch);
LOG.info("Loaded {} pages from {} in {}", loadedPages.size(), sourceFolder, stopwatch);

return loadedPages;
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public synchronized void close() {
try {
sourceWatcher.close();
} catch (IOException e) {
LOGGER.error("Failed to close fileystem watcher for {}", sourceFolder);
LOG.error("Failed to close fileystem watcher for {}", sourceFolder);
}
}
}
Expand All @@ -210,7 +210,7 @@ public boolean isWatching() {

@Override
public void onException(Exception e) {
LOGGER.error("Failed watching for changes", e);
LOG.error("Failed watching for changes", e);
}
}

Expand All @@ -228,7 +228,7 @@ private synchronized void pageChanged(Path path) {
var page = PageCompiler.parse(sourcePackId, pageId, in);
changedPages.put(pageId, page);
} catch (Exception e) {
LOGGER.error("Failed to reload guidebook page {}", path, e);
LOG.error("Failed to reload guidebook page {}", path, e);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/appeng/client/guidebook/compiler/PageCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

@ApiStatus.Internal
public final class PageCompiler {
private static final Logger LOGGER = LoggerFactory.getLogger(PageCompiler.class);
private static final Logger LOG = LoggerFactory.getLogger(PageCompiler.class);

/**
* Default gap between block-level elements. Set as margin.
Expand Down Expand Up @@ -174,13 +174,13 @@ private static Frontmatter parseFrontmatter(ResourceLocation pageId, MdAstRoot r
for (var child : root.children()) {
if (child instanceof MdAstYamlFrontmatter frontmatter) {
if (result != null) {
LOGGER.error("Found more than one frontmatter!"); // TODO: proper debugging
LOG.error("Found more than one frontmatter!"); // TODO: proper debugging
continue;
}
try {
result = Frontmatter.parse(pageId, frontmatter.value);
} catch (Exception e) {
LOGGER.error("Failed to parse frontmatter for page {}", pageId, e);
LOG.error("Failed to parse frontmatter for page {}", pageId, e);
break;
}
}
Expand Down Expand Up @@ -402,12 +402,12 @@ private LytImage compileImage(MdAstImage astImage) {
var imageId = IdUtils.resolveLink(astImage.url, pageId);
var imageContent = pages.loadAsset(imageId);
if (imageContent == null) {
LOGGER.error("Couldn't find image {}", astImage.url);
LOG.error("Couldn't find image {}", astImage.url);
image.setTitle("Missing image: " + astImage.url);
}
image.setImage(imageId, imageContent);
} catch (ResourceLocationException e) {
LOGGER.error("Invalid image id: {}", astImage.url);
LOG.error("Invalid image id: {}", astImage.url);
image.setTitle("Invalid image URL: " + astImage.url);
}
return image;
Expand Down Expand Up @@ -447,9 +447,9 @@ public LytFlowContent createErrorFlowContent(String text, UnistNode child) {
span.appendText("~".repeat(pos.column() - 1) + "^");
span.appendBreak();

LOGGER.warn("{}\n{}\n{}\n", text, line, "~".repeat(pos.column() - 1) + "^");
LOG.warn("{}\n{}\n{}\n", text, line, "~".repeat(pos.column() - 1) + "^");
} else {
LOGGER.warn("{}\n", text);
LOG.warn("{}\n", text);
}

return span;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class FloatingImageCompiler extends FlowTagCompiler {
public static final String TAG_NAME = "FloatingImage";
private static final Logger LOGGER = LoggerFactory.getLogger(FloatingImageCompiler.class);
private static final Logger LOG = LoggerFactory.getLogger(FloatingImageCompiler.class);

@Override
public Set<String> getTagNames() {
Expand All @@ -39,12 +39,12 @@ protected void compile(PageCompiler compiler, LytFlowParent parent, MdxJsxElemen
var imageId = IdUtils.resolveLink(src, compiler.getPageId());
var imageContent = compiler.loadAsset(imageId);
if (imageContent == null) {
LOGGER.error("Couldn't find image {}", src);
LOG.error("Couldn't find image {}", src);
image.setTitle("Missing image: " + src);
}
image.setImage(imageId, imageContent);
} catch (ResourceLocationException e) {
LOGGER.error("Invalid image id: {}", src);
LOG.error("Invalid image id: {}", src);
image.setTitle("Invalid image URL: " + src);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* This index is installed by default on all {@linkplain appeng.client.guidebook.Guide guides}.
*/
public class CategoryIndex extends MultiValuedIndex<String, PageAnchor> {
private static final Logger LOGGER = LoggerFactory.getLogger(CategoryIndex.class);
private static final Logger LOG = LoggerFactory.getLogger(CategoryIndex.class);

public CategoryIndex() {
super(
Expand All @@ -35,7 +35,7 @@ private static List<Pair<String, PageAnchor>> getCategories(ParsedGuidePage page
}

if (!(categoriesNode instanceof List<?> categoryList)) {
LOGGER.warn("Page {} contains malformed categories frontmatter", page.getId());
LOG.warn("Page {} contains malformed categories frontmatter", page.getId());
return List.of();
}

Expand All @@ -48,7 +48,7 @@ private static List<Pair<String, PageAnchor>> getCategories(ParsedGuidePage page
if (listEntry instanceof String categoryString) {
categories.add(Pair.of(categoryString, anchor));
} else {
LOGGER.warn("Page {} contains a malformed categories frontmatter entry: {}", page.getId(), listEntry);
LOG.warn("Page {} contains a malformed categories frontmatter entry: {}", page.getId(), listEntry);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/appeng/client/guidebook/indices/ItemIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* This index is installed by default on all {@linkplain appeng.client.guidebook.Guide guides}.
*/
public class ItemIndex extends UniqueIndex<ResourceLocation, PageAnchor> {
private static final Logger LOGGER = LoggerFactory.getLogger(ItemIndex.class);
private static final Logger LOG = LoggerFactory.getLogger(ItemIndex.class);

public ItemIndex() {
super(
Expand All @@ -38,7 +38,7 @@ private static List<Pair<ResourceLocation, PageAnchor>> getItemAnchors(ParsedGui
}

if (!(itemIdsNode instanceof List<?> itemIdList)) {
LOGGER.warn("Page {} contains malformed item_ids frontmatter", page.getId());
LOG.warn("Page {} contains malformed item_ids frontmatter", page.getId());
return List.of();
}

Expand All @@ -50,7 +50,7 @@ private static List<Pair<ResourceLocation, PageAnchor>> getItemAnchors(ParsedGui
try {
itemId = IdUtils.resolveId(itemIdStr, page.getId().getNamespace());
} catch (ResourceLocationException e) {
LOGGER.warn("Page {} contains a malformed item_ids frontmatter entry: {}", page.getId(),
LOG.warn("Page {} contains a malformed item_ids frontmatter entry: {}", page.getId(),
listEntry);
continue;
}
Expand All @@ -60,11 +60,11 @@ private static List<Pair<ResourceLocation, PageAnchor>> getItemAnchors(ParsedGui
itemAnchors.add(Pair.of(
itemId, new PageAnchor(page.getId(), null)));
} else {
LOGGER.warn("Page {} references an unknown item {} in its item_ids frontmatter",
LOG.warn("Page {} references an unknown item {} in its item_ids frontmatter",
page.getId(), itemId);
}
} else {
LOGGER.warn("Page {} contains a malformed item_ids frontmatter entry: {}", page.getId(), listEntry);
LOG.warn("Page {} contains a malformed item_ids frontmatter entry: {}", page.getId(), listEntry);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Maintains an index for any given page using a mapping function for keys and values of the index.
*/
public class UniqueIndex<K, V> implements PageIndex {
private static final Logger LOGGER = LoggerFactory.getLogger(UniqueIndex.class);
private static final Logger LOG = LoggerFactory.getLogger(UniqueIndex.class);

private final Map<K, Record<V>> index = new HashMap<>();

Expand Down Expand Up @@ -99,7 +99,7 @@ private void addToIndex(ParsedGuidePage page) {
var value = entry.getValue();
var previousPage = index.put(key, new Record<>(page.getId(), value));
if (previousPage != null) {
LOGGER.warn("Key conflict in index {}: {} is used by pages {} and {}",
LOG.warn("Key conflict in index {}: {} is used by pages {} and {}",
name, key, page, previousPage);
hadDuplicates = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

public class NavigationTree {

private static final Logger LOGGER = LoggerFactory.getLogger(NavigationTree.class);
private static final Logger LOG = LoggerFactory.getLogger(NavigationTree.class);

private final Map<ResourceLocation, NavigationNode> nodeIndex;

Expand Down Expand Up @@ -107,7 +107,7 @@ private static NavigationNode createNode(HashMap<ResourceLocation, NavigationNod

if (page == null) {
// These children had a parent that doesn't exist
LOGGER.error("Pages {} had unknown navigation parent {}", children, pageId);
LOG.error("Pages {} had unknown navigation parent {}", children, pageId);
return null;
}

Expand All @@ -120,15 +120,15 @@ private static NavigationNode createNode(HashMap<ResourceLocation, NavigationNod

if (navigationEntry.iconComponents() != null) {
var patch = DataComponentPatch.CODEC.parse(JavaOps.INSTANCE, navigationEntry.iconComponents())
.resultOrPartial(err -> LOGGER.error("Failed to deserialize component patch {} for icon {}: {}",
.resultOrPartial(err -> LOG.error("Failed to deserialize component patch {} for icon {}: {}",
navigationEntry.iconComponents(), navigationEntry.iconItemId(), err));
icon = new ItemStack(iconItem, 1, patch.orElse(DataComponentPatch.EMPTY));
} else {
icon = new ItemStack(iconItem);
}

if (icon.isEmpty()) {
LOGGER.error("Couldn't find icon {} for icon of page {}", navigationEntry.iconItemId(), page);
LOG.error("Couldn't find icon {} for icon of page {}", navigationEntry.iconItemId(), page);
}
}

Expand Down
Loading

0 comments on commit 25a4753

Please sign in to comment.