#502 Replaced usages of System.out with logger.
This commit is contained in:
		| @@ -35,6 +35,8 @@ import com.iluwatar.servicelayer.spellbook.SpellbookDaoImpl; | ||||
| import com.iluwatar.servicelayer.wizard.Wizard; | ||||
| import com.iluwatar.servicelayer.wizard.WizardDao; | ||||
| import com.iluwatar.servicelayer.wizard.WizardDaoImpl; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
|  | ||||
| /** | ||||
| @@ -57,6 +59,8 @@ import com.iluwatar.servicelayer.wizard.WizardDaoImpl; | ||||
|  */ | ||||
| public class App { | ||||
|  | ||||
|   private static final Logger LOGGER = LoggerFactory.getLogger(App.class); | ||||
|  | ||||
|   /** | ||||
|    * Program entry point | ||||
|    *  | ||||
| @@ -180,27 +184,27 @@ public class App { | ||||
|   public static void queryData() { | ||||
|     MagicService service = | ||||
|         new MagicServiceImpl(new WizardDaoImpl(), new SpellbookDaoImpl(), new SpellDaoImpl()); | ||||
|     System.out.println("Enumerating all wizards"); | ||||
|     LOGGER.info("Enumerating all wizards"); | ||||
|     for (Wizard w : service.findAllWizards()) { | ||||
|       System.out.println(w.getName()); | ||||
|       LOGGER.info(w.getName()); | ||||
|     } | ||||
|     System.out.println("Enumerating all spellbooks"); | ||||
|     LOGGER.info("Enumerating all spellbooks"); | ||||
|     for (Spellbook s : service.findAllSpellbooks()) { | ||||
|       System.out.println(s.getName()); | ||||
|       LOGGER.info(s.getName()); | ||||
|     } | ||||
|     System.out.println("Enumerating all spells"); | ||||
|     LOGGER.info("Enumerating all spells"); | ||||
|     for (Spell s : service.findAllSpells()) { | ||||
|       System.out.println(s.getName()); | ||||
|       LOGGER.info(s.getName()); | ||||
|     } | ||||
|     System.out.println("Find wizards with spellbook 'Book of Idores'"); | ||||
|     LOGGER.info("Find wizards with spellbook 'Book of Idores'"); | ||||
|     List<Wizard> wizardsWithSpellbook = service.findWizardsWithSpellbook("Book of Idores"); | ||||
|     for (Wizard w : wizardsWithSpellbook) { | ||||
|       System.out.println(String.format("%s has 'Book of Idores'", w.getName())); | ||||
|       LOGGER.info("{} has 'Book of Idores'", w.getName()); | ||||
|     } | ||||
|     System.out.println("Find wizards with spell 'Fireball'"); | ||||
|     LOGGER.info("Find wizards with spell 'Fireball'"); | ||||
|     List<Wizard> wizardsWithSpell = service.findWizardsWithSpell("Fireball"); | ||||
|     for (Wizard w : wizardsWithSpell) { | ||||
|       System.out.println(String.format("%s has 'Fireball'", w.getName())); | ||||
|       LOGGER.info("{} has 'Fireball'", w.getName()); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -28,12 +28,16 @@ import com.iluwatar.servicelayer.wizard.Wizard; | ||||
|  | ||||
| import org.hibernate.SessionFactory; | ||||
| import org.hibernate.cfg.Configuration; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| /** | ||||
|  * Produces the Hibernate {@link SessionFactory}. | ||||
|  */ | ||||
| public final class HibernateUtil { | ||||
|  | ||||
|   private static final Logger LOGGER = LoggerFactory.getLogger(HibernateUtil.class); | ||||
|  | ||||
|   /** | ||||
|    * The cached session factory | ||||
|    */ | ||||
| @@ -59,7 +63,7 @@ public final class HibernateUtil { | ||||
|                 .setProperty("hibernate.show_sql", "true") | ||||
|                 .setProperty("hibernate.hbm2ddl.auto", "create-drop").buildSessionFactory(); | ||||
|       } catch (Throwable ex) { | ||||
|         System.err.println("Initial SessionFactory creation failed." + ex); | ||||
|         LOGGER.error("Initial SessionFactory creation failed.", ex); | ||||
|         throw new ExceptionInInitializerError(ex); | ||||
|       } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user