Skip to content

Commit

Permalink
Logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Mar 7, 2024
1 parent cda76e8 commit 31179da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/meeuw/i18n/languages/ISO_639.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.meeuw.i18n.languages;

import java.util.*;
import java.util.logging.Level;
import java.util.stream.Stream;

import javax.validation.constraints.Size;
Expand Down Expand Up @@ -76,7 +77,7 @@ public static Optional<LanguageCode> getByPart2T(String code) {
*/
public static Optional<LanguageCode> getByPart3(@Size(min = 3, max = 3) String code, boolean matchRetired) {

return ISO_639_3_Code.getByPart3(code, matchRetired)
return ISO_639_3_Code.getByPart3(code, matchRetired, Level.WARNING)
.map(LanguageCode::updateToEnum)
;
}
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/org/meeuw/i18n/languages/ISO_639_3_Code.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package org.meeuw.i18n.languages;

import com.fasterxml.jackson.annotation.JsonValue;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.fasterxml.jackson.annotation.JsonValue;

/**
* Implementation of {@link LanguageCode} that {@link ISO_639#stream() produces} all ISO-639-3 codes.
* <p>
Expand Down Expand Up @@ -86,12 +88,12 @@ public class ISO_639_3_Code implements LanguageCode {
String[] split = line.split("\t");
ISO_639_3_Code macro = KNOWN.get(split[0]);
List<LanguageCode> list = tempIndividual.computeIfAbsent(macro, (m) -> new ArrayList<>());
Optional<ISO_639_3_Code> individual = getByPart3(split[1], true);
Optional<ISO_639_3_Code> individual = getByPart3(split[1], true, Level.FINEST);
if (individual.isPresent()) {
list.add(LanguageCode.updateToEnum(individual.get()));
tempMacro.computeIfAbsent(individual.get(), (m) -> new ArrayList<>()).add(LanguageCode.updateToEnum(macro));
} else {
System.out.println("Unknown individual language: " + split[1] + " for " + macro);
LOGGER.log(Level.FINEST, "Unknown individual language: " + split[1] + " for " + macro);
}
line = inputStreamReader.readLine();
}
Expand Down Expand Up @@ -150,7 +152,7 @@ static Optional<ISO_639_3_Code> getByPart1(String code) {
* @return An optional containing the {@link ISO_639_3_Code} if found.
* @since 2.2
*/
static Optional<ISO_639_3_Code> getByPart3(@Size(min = 3, max=3) String code, boolean matchRetired) {
static Optional<ISO_639_3_Code> getByPart3(@Size(min = 3, max=3) String code, boolean matchRetired, Level level) {
if (code == null) {
return Optional.empty();
}
Expand All @@ -161,7 +163,7 @@ static Optional<ISO_639_3_Code> getByPart3(@Size(min = 3, max=3) String code, bo
try {
prop = KNOWN.get(retiredLanguageCode.get().changeTo().part3());
} catch (RetiredLanguageCode.RetirementException e) {
LOGGER.log(Level.WARNING, "Could not find single replacement for " + code + " " + e.getMessage());
LOGGER.log(level, "Could not find single replacement for " + code + " " + e.getMessage());
}
}
}
Expand Down

0 comments on commit 31179da

Please sign in to comment.