diff --git a/docs/content/v1.0.x-kor/docs/generating-objects/introspector.md b/docs/content/v1.0.x-kor/docs/generating-objects/introspector.md index ed8a46183..34846d1c9 100644 --- a/docs/content/v1.0.x-kor/docs/generating-objects/introspector.md +++ b/docs/content/v1.0.x-kor/docs/generating-objects/introspector.md @@ -78,6 +78,12 @@ FixtureMonkey sut = FixtureMonkey.builder() .build(); ``` +생성에 실패하면 발생하는 로그를 보고싶지 않다면 생성자 파라미터 `enableLoggingFail`를 false로 설정하면 됩니다. + +```java +FailoverIntrospector failoverIntrospector = new FailoverIntrospector(introspectors, false); +``` + ## PriorityConstructorArbitraryIntrospector 픽스쳐 몽키에서 기본으로 생성을 지원하지 않는 타입은 사용자 정의 `ArbitraryIntrospector`를 사용하면 생성할 수 있습니다. 하지만 픽스쳐 몽키에 익숙하지 않다면 `ArbitraryIntrospector`를 만들기는 어렵습니다. diff --git a/docs/content/v1.0.x-kor/release-notes/_index.md b/docs/content/v1.0.x-kor/release-notes/_index.md index 393790208..980b65a70 100644 --- a/docs/content/v1.0.x-kor/release-notes/_index.md +++ b/docs/content/v1.0.x-kor/release-notes/_index.md @@ -5,6 +5,12 @@ menu: docs: weight: 100 --- +sectionStart +## v.1.0.27 +Add `enableLoggingFail` option as a constructor argument in `FailoverIntrospector` + +sectionEnd + sectionStart ## v.1.0.26 Add `PriorityConstructorArbitraryIntrospector` diff --git a/docs/content/v1.0.x/docs/generating-objects/introspector.md b/docs/content/v1.0.x/docs/generating-objects/introspector.md index 2cd3e2378..8a985fbbe 100644 --- a/docs/content/v1.0.x/docs/generating-objects/introspector.md +++ b/docs/content/v1.0.x/docs/generating-objects/introspector.md @@ -78,6 +78,12 @@ FixtureMonkey sut = FixtureMonkey.builder() .build(); ``` +If you want to disable the fail log, you should set the constructor argument `enableLoggingFail` to false. + +```java +FailoverIntrospector failoverIntrospector = new FailoverIntrospector(introspectors, false); +``` + ## PriorityConstructorArbitraryIntrospector Types that Fixture Monkey does not support creating by default can be created using a custom `ArbitraryIntrospector`. However, creating your own `ArbitraryIntrospector` can be difficult if you are not familiar with Fixture Monkey. diff --git a/docs/content/v1.0.x/release-notes/_index.md b/docs/content/v1.0.x/release-notes/_index.md index 0656ce397..9e1f7a77b 100644 --- a/docs/content/v1.0.x/release-notes/_index.md +++ b/docs/content/v1.0.x/release-notes/_index.md @@ -5,6 +5,12 @@ menu: docs: weight: 100 --- +sectionStart +## v.1.0.27 +Add `enableLoggingFail` option as a constructor argument in `FailoverIntrospector` + +sectionEnd + sectionStart ## v.1.0.26 Add `PriorityConstructorArbitraryIntrospector` diff --git a/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/introspector/FailoverIntrospector.java b/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/introspector/FailoverIntrospector.java index 3bd7148ae..bd96a837a 100644 --- a/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/introspector/FailoverIntrospector.java +++ b/fixture-monkey-api/src/main/java/com/navercorp/fixturemonkey/api/introspector/FailoverIntrospector.java @@ -36,9 +36,15 @@ public final class FailoverIntrospector implements ArbitraryIntrospector { private static final Logger LOGGER = LoggerFactory.getLogger(FailoverIntrospector.class); private final List introspectors; + private final boolean enableLoggingFail; public FailoverIntrospector(List introspectors) { + this(introspectors, true); + } + + public FailoverIntrospector(List introspectors, boolean enableLoggingFail) { this.introspectors = introspectors; + this.enableLoggingFail = enableLoggingFail; } @Override @@ -51,14 +57,16 @@ public ArbitraryIntrospectorResult introspect(ArbitraryGeneratorContext context) results.add(new FailoverIntrospectorResult(introspector, result)); } } catch (Exception ex) { - LOGGER.warn( - String.format( - "\"%s\" is failed to introspect \"%s\" type.", - introspector.getClass().getSimpleName(), - ((Class)context.getResolvedProperty().getType()).getName() - ), - ex - ); + if (enableLoggingFail) { + LOGGER.warn( + String.format( + "\"%s\" is failed to introspect \"%s\" type.", + introspector.getClass().getSimpleName(), + ((Class)context.getResolvedProperty().getType()).getName() + ), + ex + ); + } // omitted } } @@ -77,14 +85,16 @@ public Object combined() { result = iterator.next(); return result.getResult().getValue().combined(); } catch (Exception ex) { - LOGGER.warn( - String.format( - "\"%s\" is failed to introspect \"%s\" type.", - Objects.requireNonNull(result).getIntrospector().getClass().getSimpleName(), - ((Class)context.getResolvedProperty().getType()).getName() - ), - ex - ); + if (enableLoggingFail) { + LOGGER.warn( + String.format( + "\"%s\" is failed to introspect \"%s\" type.", + Objects.requireNonNull(result).getIntrospector().getClass().getSimpleName(), + ((Class)context.getResolvedProperty().getType()).getName() + ), + ex + ); + } // omitted } } @@ -105,14 +115,16 @@ public Object rawValue() { result = iterator.next(); return result.getResult().getValue().rawValue(); } catch (Exception ex) { - LOGGER.warn( - String.format( - "\"%s\" is failed to introspect type \"%s\"", - Objects.requireNonNull(result).getIntrospector().getClass().getSimpleName(), - ((Class)context.getResolvedProperty().getType()).getName() - ), - ex - ); + if (enableLoggingFail) { + LOGGER.warn( + String.format( + "\"%s\" is failed to introspect type \"%s\"", + Objects.requireNonNull(result).getIntrospector().getClass().getSimpleName(), + ((Class)context.getResolvedProperty().getType()).getName() + ), + ex + ); + } // omitted } }