From d7688e88cb581e805ab3ddbae9cdca7d2a5c2bbb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Jun 2025 12:22:44 +0000 Subject: [PATCH 1/2] Initial plan for issue From e9bb4a655d9f7394598ef06462583fbbf2484de5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 17 Jun 2025 12:29:54 +0000 Subject: [PATCH 2/2] Add ASCII sun art and suppress INFO logger messages from CLI output Co-authored-by: EficodeRjpalt <91126255+EficodeRjpalt@users.noreply.github.com> --- src/main/art/sun.txt | 13 +++++ src/main/java/com/weather/app/WeatherApp.java | 49 ++++++++++++++++--- src/main/resources/art/sun.txt | 13 +++++ src/main/resources/logging.properties | 10 ++-- 4 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 src/main/art/sun.txt create mode 100644 src/main/resources/art/sun.txt diff --git a/src/main/art/sun.txt b/src/main/art/sun.txt new file mode 100644 index 0000000..4f5891b --- /dev/null +++ b/src/main/art/sun.txt @@ -0,0 +1,13 @@ + \ | / + \ | / + --- \ | / --- + \ | / + --- \|/ --- + ====== * ====== + --- /|\ --- + / | \ + --- / | \ --- + / | \ + / | \ + + ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ \ No newline at end of file diff --git a/src/main/java/com/weather/app/WeatherApp.java b/src/main/java/com/weather/app/WeatherApp.java index 3cb8a8d..01b9448 100644 --- a/src/main/java/com/weather/app/WeatherApp.java +++ b/src/main/java/com/weather/app/WeatherApp.java @@ -1,7 +1,9 @@ package com.weather.app; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; +import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.Logger; @@ -54,18 +56,53 @@ private static boolean exit(int status) { return true; } + /** + * Load ASCII art from a resource file + * + * @param filename the name of the art file to load + * @return the ASCII art as a string, or empty string if not found + */ + private static String loadAsciiArt(String filename) { + StringBuilder art = new StringBuilder(); + try (InputStream is = WeatherApp.class.getClassLoader().getResourceAsStream("art/" + filename); + BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { + + String line; + while ((line = reader.readLine()) != null) { + art.append(line).append(System.lineSeparator()); + } + } catch (IOException | NullPointerException e) { + LOGGER.log(Level.FINE, "Could not load ASCII art file: " + filename, e); + } + return art.toString(); + } + + /** + * Display weather data with ASCII sun art + * + * @param weatherData the weather data to display + */ + private static void displayWeatherWithArt(WeatherData weatherData) { + System.out.println(); + System.out.println(loadAsciiArt("sun.txt")); + System.out.println("Current Weather for " + weatherData.getCity() + ":"); + System.out.println("========================================"); + System.out.println(weatherData); + System.out.println(); + } + public static void main(String[] args) { // Validate command line arguments if (args.length < 1) { - LOGGER.log(Level.INFO, "Usage: java -jar WeatherApp.jar "); - LOGGER.log(Level.INFO, "Example: java -jar WeatherApp.jar London"); + System.out.println("Usage: java -jar WeatherApp.jar "); + System.out.println("Example: java -jar WeatherApp.jar London"); exit(1); return; } // Get the city name from command line arguments String city = args[0]; - LOGGER.log(Level.INFO, "Weather request for city: {0}", city); + LOGGER.log(Level.FINE, "Weather request for city: {0}", city); try { // Get API key from environment or config file @@ -79,10 +116,8 @@ public static void main(String[] args) { WeatherData weatherData = weatherService.getWeather(city); LOGGER.log(Level.FINE, weatherData.toString()); - // Display weather data to the user - System.out.println("Current Weather for " + city + ":"); - System.out.println("-------------------------------------"); - System.out.println(weatherData); + // Display weather data to the user with ASCII art + displayWeatherWithArt(weatherData); } catch (ConfigUtil.ConfigException e) { LOGGER.log(Level.SEVERE, "Configuration error: " + e.getMessage(), e); diff --git a/src/main/resources/art/sun.txt b/src/main/resources/art/sun.txt new file mode 100644 index 0000000..4f5891b --- /dev/null +++ b/src/main/resources/art/sun.txt @@ -0,0 +1,13 @@ + \ | / + \ | / + --- \ | / --- + \ | / + --- \|/ --- + ====== * ====== + --- /|\ --- + / | \ + --- / | \ --- + / | \ + / | \ + + ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ ☀️ \ No newline at end of file diff --git a/src/main/resources/logging.properties b/src/main/resources/logging.properties index ba567ac..42e8112 100644 --- a/src/main/resources/logging.properties +++ b/src/main/resources/logging.properties @@ -1,15 +1,15 @@ # Default global logging level -.level=INFO +.level=SEVERE # Root logger handlers handlers=java.util.logging.ConsoleHandler -# ConsoleHandler configuration -java.util.logging.ConsoleHandler.level=INFO +# ConsoleHandler configuration - only show SEVERE and WARNING messages +java.util.logging.ConsoleHandler.level=WARNING java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter # SimpleFormatter configuration java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] [%4$-7s] %2$s - %5$s %n -# Application specific logging levels -com.weather.app.level=INFO +# Application specific logging levels - suppress INFO messages from console +com.weather.app.level=WARNING