GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — #502 Replaced usages of System.out with logger. · coding0011/java-design-patterns@0438811

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • abstract-document/src/main/java/com/iluwatar/abstractdocument
    • App.java
  • abstract-factory/src/main/java/com/iluwatar/abstractfactory
    • App.java
  • adapter/src/main/java/com/iluwatar/adapter
    • BattleFishingBoat.java
    • FishingBoat.java
  • aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices
    • ProductInformationClientImpl.java
    • ProductInventoryClientImpl.java
  • async-method-invocation/src/main/java/com/iluwatar/async/method/invocation
    • App.java
  • bridge/src/main/java/com/iluwatar/bridge
    • Excalibur.java
    • Mjollnir.java
    • Stormbringer.java
  • builder/src/main/java/com/iluwatar/builder
    • App.java
  • business-delegate/src/main/java/com/iluwatar/business/delegate
    • EjbService.java
    • JmsService.java
  • caching/src/main/java/com/iluwatar/caching
    • App.java
    • CacheStore.java
    • LruCache.java
  • callback/src/main/java/com/iluwatar/callback
    • App.java
    • LambdasApp.java
    • SimpleTask.java
  • chain/src/main/java/com/iluwatar/chain
    • RequestHandler.java
  • command/src/main/java/com/iluwatar/command
    • Target.java
    • Wizard.java
  • composite/src/main/java/com/iluwatar/composite
    • App.java
    • Letter.java
    • Sentence.java
    • Word.java
  • decorator/src/main/java/com/iluwatar/decorator
    • App.java
    • SmartHostile.java
    • Troll.java
  • delegation/src/main/java/com/iluwatar/delegation/simple/printers
    • CanonPrinter.java
    • EpsonPrinter.java
    • HpPrinter.java
  • dependency-injection/src/main/java/com/iluwatar/dependency/injection
    • Tobacco.java
  • double-checked-locking/src/main/java/com/iluwatar/doublechecked/locking
    • App.java
    • Inventory.java
  • double-dispatch/src/main/java/com/iluwatar/doubledispatch
    • App.java
    • Meteoroid.java
    • SpaceStationMir.java
  • event-aggregator/src/main/java/com/iluwatar/event/aggregator
    • KingJoffrey.java
  • event-driven-architecture/src/main/java/com/iluwatar/eda/handler
    • UserCreatedEventHandler.java
    • UserUpdatedEventHandler.java
  • facade/src/main/java/com/iluwatar/facade
    • DwarvenCartOperator.java
    • DwarvenGoldDigger.java
    • DwarvenMineWorker.java
    • DwarvenTunnelDigger.java
  • factory-kit/src/main/java/com/iluwatar/factorykit
    • App.java
  • factory-method/src/main/java/com/iluwatar/factory/method
    • App.java
  • feature-toggle/src/main/java/com/iluwatar/featuretoggle
    • App.java
  • fluentinterface/src/main/java/com/iluwatar/fluentinterface/app
    • App.java
  • flux/src/main/java/com/iluwatar/flux/view
    • ContentView.java
    • MenuView.java
  • flyweight/src/main/java/com/iluwatar/flyweight
    • AlchemistShop.java
    • HealingPotion.java
    • HolyWaterPotion.java
    • InvisibilityPotion.java
    • PoisonPotion.java
    • StrengthPotion.java
  • front-controller/src/main/java/com/iluwatar/front/controller
    • ArcherView.java
    • CatapultView.java
    • ErrorView.java
  • half-sync-half-async/src/main/java/com/iluwatar/halfsynchalfasync
    • App.java
  • hexagonal/src/main/java/com/iluwatar/hexagonal
    • administration
      • ConsoleAdministration.java
    • eventlog
      • StdOutEventLog.java
    • service
      • ConsoleLottery.java
  • interpreter/src/main/java/com/iluwatar/interpreter
    • App.java
  • iterator/src/main/java/com/iluwatar/iterator
    • App.java
  • layers/src
    • main/java/com/iluwatar/layers
      • CakeViewImpl.java
    • test/java/com/iluwatar/layers
      • StdOutTest.java
  • lazy-loading/src/main/java/com/iluwatar/lazy/loading
    • App.java
    • Heavy.java
    • HolderNaive.java
    • HolderThreadSafe.java
    • Java8Holder.java
  • mediator/src/main/java/com/iluwatar/mediator
    • PartyMemberBase.java
  • memento/src/main/java/com/iluwatar/memento
    • App.java
  • message-channel/src/main/java/com/iluwatar/message/channel
    • App.java
  • model-view-controller/src/main/java/com/iluwatar/model/view/controller
    • GiantView.java
  • monad/src/main/java/com/iluwatar/monad
    • App.java
  • monostate/src/main/java/com/iluwatar/monostate
    • Server.java
  • multiton/src/main/java/com/iluwatar/multiton
    • App.java
  • mute-idiom/src
    • main/java/com/iluwatar/mute
      • App.java
    • test/java/com/iluwatar/mute
      • MuteTest.java
  • mutex/src/main/java/com/iluwatar/mutex
    • Thief.java
  • naked-objects
    • dom
      • log4j.properties
    • integtests
      • logging.properties
    • webapp/src/main/webapp/WEB-INF
      • logging.properties
  • null-object/src/main/java/com/iluwatar/nullobject
    • NodeImpl.java
  • object-pool/src/main/java/com/iluwatar/object/pool
    • App.java
  • observer/src/main/java/com/iluwatar/observer
    • App.java
    • Hobbits.java
    • Orcs.java
    • Weather.java
    • generic
      • GHobbits.java
      • GOrcs.java
      • GWeather.java
  • poison-pill/src/main/java/com/iluwatar/poison/pill
    • Consumer.java
    • Producer.java
  • pom.xml
  • private-class-data/src/main/java/com/iluwatar/privateclassdata
    • ImmutableStew.java
    • Stew.java
  • producer-consumer/src/main/java/com/iluwatar/producer/consumer
    • App.java
    • Consumer.java
  • promise/src/main/java/com/iluwatar/promise
    • App.java
    • Utility.java
  • property/src/main/java/com/iluwatar/property
    • App.java
  • prototype/src/main/java/com/iluwatar/prototype
    • App.java
  • proxy/src/main/java/com/iluwatar/proxy
    • WizardTower.java
    • WizardTowerProxy.java
  • publish-subscribe/src/main/java/com/iluwatar/publish/subscribe
    • App.java
  • reactor/src/main/java/com/iluwatar/reactor
    • app
      • AppClient.java
      • LoggingHandler.java
    • framework
      • NioDatagramChannel.java
      • NioReactor.java
      • NioServerSocketChannel.java
  • reader-writer-lock/src
    • main/java/com/iluwatar/reader/writer/lock
      • App.java
      • Reader.java
      • Writer.java
    • test/java/com/iluwatar/reader/writer/lock
      • ReaderAndWriterTest.java
      • ReaderTest.java
      • WriterTest.java
  • repository/src/main/java/com/iluwatar/repository
    • App.java
    • AppConfig.java
  • resource-acquisition-is-initialization/src/main/java/com/iluwatar/resource/acquisition/is/initialization
    • App.java
    • SlidingDoor.java
    • TreasureChest.java
  • semaphore/src/main/java/com/iluwatar/semaphore
    • Customer.java
  • servant/src/main/java/com/iluwatar/servant
    • App.java
  • service-layer/src/main/java/com/iluwatar/servicelayer
    • app
      • App.java
    • hibernate
      • HibernateUtil.java
  • service-locator/src/main/java/com/iluwatar/servicelocator
    • InitContext.java
    • ServiceCache.java
    • ServiceImpl.java
  • singleton/src/main/java/com/iluwatar/singleton
    • App.java
  • specification/src/main/java/com/iluwatar/specification/app
    • App.java
  • state/src/main/java/com/iluwatar/state
    • AngryState.java
    • PeacefulState.java
  • step-builder/src/main/java/com/iluwatar/stepbuilder
    • App.java
  • strategy/src/main/java/com/iluwatar/strategy
    • App.java
    • MeleeStrategy.java
    • ProjectileStrategy.java
    • SpellStrategy.java
  • template-method/src/main/java/com/iluwatar/templatemethod
    • HitAndRunMethod.java
    • StealingMethod.java
    • SubtleMethod.java
  • thread-pool/src/main/java/com/iluwatar/threadpool
    • App.java
    • Worker.java
  • tolerant-reader/src/main/java/com/iluwatar/tolerantreader
    • App.java
  • twin/src/main/java/com/iluwatar/twin
    • BallItem.java
    • BallThread.java
    • GameItem.java
  • value-object/src/main/java/com/iluwatar/value/object
    • App.java
  • visitor/src/main/java/com/iluwatar/visitor
    • CommanderVisitor.java
    • SergeantVisitor.java
    • SoldierVisitor.java

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎abstract-document/src/main/java/com/iluwatar/abstractdocument/App.java‎

Copy file name to clipboardExpand all lines: abstract-document/src/main/java/com/iluwatar/abstractdocument/App.java
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import com.iluwatar.abstractdocument.domain.HasParts;
2828
import com.iluwatar.abstractdocument.domain.HasPrice;
2929
import com.iluwatar.abstractdocument.domain.HasType;
30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
3032

3133
import java.util.Arrays;
3234
import java.util.HashMap;
@@ -44,11 +46,13 @@
4446
*/
4547
public class App {
4648

49+
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
50+
4751
/**
4852
* Executes the App
4953
*/
5054
public App() {
51-
System.out.println("Constructing parts and car");
55+
LOGGER.info("Constructing parts and car");
5256

5357
Map<String, Object> carProperties = new HashMap<>();
5458
carProperties.put(HasModel.PROPERTY, "300SL");
@@ -68,12 +72,11 @@ public App() {
6872

6973
Car car = new Car(carProperties);
7074

71-
System.out.println("Here is our car:");
72-
System.out.println("-> model: " + car.getModel().get());
73-
System.out.println("-> price: " + car.getPrice().get());
74-
System.out.println("-> parts: ");
75-
car.getParts().forEach(p -> System.out
76-
.println("\t" + p.getType().get() + "/" + p.getModel().get() + "/" + p.getPrice().get()));
75+
LOGGER.info("Here is our car:");
76+
LOGGER.info("-> model: {}", car.getModel().get());
77+
LOGGER.info("-> price: {}", car.getPrice().get());
78+
LOGGER.info("-> parts: ");
79+
car.getParts().forEach(p -> LOGGER.info("\t{}/{}/{}", p.getType().get(), p.getModel().get(), p.getPrice().get()));
7780
}
7881

7982
/**
Collapse file

‎abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java‎

Copy file name to clipboardExpand all lines: abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
package com.iluwatar.abstractfactory;
2424

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2528
/**
2629
*
2730
* The Abstract Factory pattern provides a way to encapsulate a group of individual factories that have a common theme
@@ -39,6 +42,8 @@
3942
*/
4043
public class App {
4144

45+
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
46+
4247
private King king;
4348
private Castle castle;
4449
private Army army;
@@ -98,17 +103,17 @@ public static void main(String[] args) {
98103

99104
App app = new App();
100105

101-
System.out.println("Elf Kingdom");
106+
LOGGER.info("Elf Kingdom");
102107
app.createKingdom(new ElfKingdomFactory());
103-
System.out.println(app.getArmy().getDescription());
104-
System.out.println(app.getCastle().getDescription());
105-
System.out.println(app.getKing().getDescription());
108+
LOGGER.info(app.getArmy().getDescription());
109+
LOGGER.info(app.getCastle().getDescription());
110+
LOGGER.info(app.getKing().getDescription());
106111

107-
System.out.println("\nOrc Kingdom");
112+
LOGGER.info("Orc Kingdom");
108113
app.createKingdom(new OrcKingdomFactory());
109-
System.out.println(app.getArmy().getDescription());
110-
System.out.println(app.getCastle().getDescription());
111-
System.out.println(app.getKing().getDescription());
114+
LOGGER.info(app.getArmy().getDescription());
115+
LOGGER.info(app.getCastle().getDescription());
116+
LOGGER.info(app.getKing().getDescription());
112117

113118
}
114119

Collapse file

‎adapter/src/main/java/com/iluwatar/adapter/BattleFishingBoat.java‎

Copy file name to clipboardExpand all lines: adapter/src/main/java/com/iluwatar/adapter/BattleFishingBoat.java
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
package com.iluwatar.adapter;
2424

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2528
/**
2629
*
2730
* Adapter class. Adapts the interface of the device ({@link FishingBoat}) into {@link BattleShip}
@@ -33,6 +36,8 @@
3336
*/
3437
public class BattleFishingBoat implements BattleShip {
3538

39+
private static final Logger LOGGER = LoggerFactory.getLogger(BattleFishingBoat.class);
40+
3641
private FishingBoat boat;
3742

3843
public BattleFishingBoat() {
@@ -41,7 +46,7 @@ public BattleFishingBoat() {
4146

4247
@Override
4348
public void fire() {
44-
System.out.println("fire!");
49+
LOGGER.info("fire!");
4550
}
4651

4752
@Override
Collapse file

‎adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java‎

Copy file name to clipboardExpand all lines: adapter/src/main/java/com/iluwatar/adapter/FishingBoat.java
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,24 @@
2222
*/
2323
package com.iluwatar.adapter;
2424

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2528
/**
2629
*
2730
* Device class (adaptee in the pattern). We want to reuse this class
2831
*
2932
*/
3033
public class FishingBoat {
3134

35+
private static final Logger LOGGER = LoggerFactory.getLogger(FishingBoat.class);
36+
3237
public void sail() {
33-
System.out.println("The Boat is moving to that place");
38+
LOGGER.info("The Boat is moving to that place");
3439
}
3540

3641
public void fish() {
37-
System.out.println("fishing ...");
42+
LOGGER.info("fishing ...");
3843
}
3944

4045
}
Collapse file

‎aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java‎

Copy file name to clipboardExpand all lines: aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInformationClientImpl.java
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.apache.http.impl.client.CloseableHttpClient;
2828
import org.apache.http.impl.client.HttpClients;
2929
import org.apache.http.util.EntityUtils;
30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
3032
import org.springframework.stereotype.Component;
3133

3234
import java.io.IOException;
@@ -37,6 +39,8 @@
3739
@Component
3840
public class ProductInformationClientImpl implements ProductInformationClient {
3941

42+
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInformationClientImpl.class);
43+
4044
@Override
4145
public String getProductTitle() {
4246
String response = null;
@@ -46,7 +50,7 @@ public String getProductTitle() {
4650
response = EntityUtils.toString(httpResponse.getEntity());
4751
}
4852
} catch (IOException e) {
49-
e.printStackTrace();
53+
LOGGER.error("Exception caught.", e);
5054
}
5155
return response;
5256
}
Collapse file

‎aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java‎

Copy file name to clipboardExpand all lines: aggregator-microservices/aggregator-service/src/main/java/com/iluwatar/aggregator/microservices/ProductInventoryClientImpl.java
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.apache.http.impl.client.CloseableHttpClient;
2828
import org.apache.http.impl.client.HttpClients;
2929
import org.apache.http.util.EntityUtils;
30+
import org.slf4j.Logger;
31+
import org.slf4j.LoggerFactory;
3032
import org.springframework.stereotype.Component;
3133

3234
import java.io.IOException;
@@ -37,6 +39,8 @@
3739
@Component
3840
public class ProductInventoryClientImpl implements ProductInventoryClient {
3941

42+
private static final Logger LOGGER = LoggerFactory.getLogger(ProductInventoryClientImpl.class);
43+
4044
@Override
4145
public int getProductInventories() {
4246
String response = "0";
@@ -46,7 +50,7 @@ public int getProductInventories() {
4650
response = EntityUtils.toString(httpResponse.getEntity());
4751
}
4852
} catch (IOException e) {
49-
e.printStackTrace();
53+
LOGGER.error("Exception caught.", e);
5054
}
5155
return Integer.parseInt(response);
5256
}
Collapse file

‎async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java‎

Copy file name to clipboardExpand all lines: async-method-invocation/src/main/java/com/iluwatar/async/method/invocation/App.java
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
*/
2323
package com.iluwatar.async.method.invocation;
2424

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2528
import java.util.concurrent.Callable;
2629

2730
/**
@@ -54,6 +57,8 @@
5457
*/
5558
public class App {
5659

60+
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
61+
5762
/**
5863
* Program entry point
5964
*/
@@ -120,6 +125,6 @@ private static <T> AsyncCallback<T> callback(String name) {
120125
}
121126

122127
private static void log(String msg) {
123-
System.out.println(String.format("[%1$-10s] - %2$s", Thread.currentThread().getName(), msg));
128+
LOGGER.info(msg);
124129
}
125130
}
Collapse file

‎bridge/src/main/java/com/iluwatar/bridge/Excalibur.java‎

Copy file name to clipboardExpand all lines: bridge/src/main/java/com/iluwatar/bridge/Excalibur.java
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,35 @@
2222
*/
2323
package com.iluwatar.bridge;
2424

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2528
/**
2629
*
2730
* Excalibur
2831
*
2932
*/
3033
public class Excalibur extends BlindingMagicWeaponImpl {
3134

35+
private static final Logger LOGGER = LoggerFactory.getLogger(Excalibur.class);
36+
3237
@Override
3338
public void wieldImp() {
34-
System.out.println("wielding Excalibur");
39+
LOGGER.info("wielding Excalibur");
3540
}
3641

3742
@Override
3843
public void swingImp() {
39-
System.out.println("swinging Excalibur");
44+
LOGGER.info("swinging Excalibur");
4045
}
4146

4247
@Override
4348
public void unwieldImp() {
44-
System.out.println("unwielding Excalibur");
49+
LOGGER.info("unwielding Excalibur");
4550
}
4651

4752
@Override
4853
public void blindImp() {
49-
System.out.println("bright light streams from Excalibur blinding the enemy");
54+
LOGGER.info("bright light streams from Excalibur blinding the enemy");
5055
}
5156
}
Collapse file

‎bridge/src/main/java/com/iluwatar/bridge/Mjollnir.java‎

Copy file name to clipboardExpand all lines: bridge/src/main/java/com/iluwatar/bridge/Mjollnir.java
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,35 @@
2222
*/
2323
package com.iluwatar.bridge;
2424

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2528
/**
2629
*
2730
* Mjollnir
2831
*
2932
*/
3033
public class Mjollnir extends FlyingMagicWeaponImpl {
3134

35+
private static final Logger LOGGER = LoggerFactory.getLogger(Mjollnir.class);
36+
3237
@Override
3338
public void wieldImp() {
34-
System.out.println("wielding Mjollnir");
39+
LOGGER.info("wielding Mjollnir");
3540
}
3641

3742
@Override
3843
public void swingImp() {
39-
System.out.println("swinging Mjollnir");
44+
LOGGER.info("swinging Mjollnir");
4045
}
4146

4247
@Override
4348
public void unwieldImp() {
44-
System.out.println("unwielding Mjollnir");
49+
LOGGER.info("unwielding Mjollnir");
4550
}
4651

4752
@Override
4853
public void flyImp() {
49-
System.out.println("Mjollnir hits the enemy in the air and returns back to the owner's hand");
54+
LOGGER.info("Mjollnir hits the enemy in the air and returns back to the owner's hand");
5055
}
5156
}
Collapse file

‎bridge/src/main/java/com/iluwatar/bridge/Stormbringer.java‎

Copy file name to clipboardExpand all lines: bridge/src/main/java/com/iluwatar/bridge/Stormbringer.java
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,35 @@
2222
*/
2323
package com.iluwatar.bridge;
2424

25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
2528
/**
2629
*
2730
* Stormbringer
2831
*
2932
*/
3033
public class Stormbringer extends SoulEatingMagicWeaponImpl {
3134

35+
private static final Logger LOGGER = LoggerFactory.getLogger(Stormbringer.class);
36+
3237
@Override
3338
public void wieldImp() {
34-
System.out.println("wielding Stormbringer");
39+
LOGGER.info("wielding Stormbringer");
3540
}
3641

3742
@Override
3843
public void swingImp() {
39-
System.out.println("swinging Stormbringer");
44+
LOGGER.info("swinging Stormbringer");
4045
}
4146

4247
@Override
4348
public void unwieldImp() {
44-
System.out.println("unwielding Stormbringer");
49+
LOGGER.info("unwielding Stormbringer");
4550
}
4651

4752
@Override
4853
public void eatSoulImp() {
49-
System.out.println("Stormbringer devours the enemy's soul");
54+
LOGGER.info("Stormbringer devours the enemy's soul");
5055
}
5156
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.