diff --git a/maps4fs/generator/background.py b/maps4fs/generator/background.py index 3dc7736..6e1e274 100644 --- a/maps4fs/generator/background.py +++ b/maps4fs/generator/background.py @@ -143,7 +143,7 @@ def generate_obj_files(self) -> None: self.logger.warning("DEM file not found, generation will be stopped: %s", dem_path) return - self.logger.info("DEM file for tile %s found: %s", tile.code, dem_path) + self.logger.debug("DEM file for tile %s found: %s", tile.code, dem_path) base_directory = os.path.dirname(dem_path) save_path = os.path.join(base_directory, f"{tile.code}.obj") @@ -164,7 +164,6 @@ def plane_from_np(self, tile_code: str, dem_data: np.ndarray, save_path: str) -> if tile_code == PATH_FULL_NAME: resize_factor = FULL_RESIZE_FACTOR simplify_factor = FULL_SIMPLIFY_FACTOR - self.logger.info("Generating a full map obj file") else: resize_factor = RESIZE_FACTOR simplify_factor = SIMPLIFY_FACTOR diff --git a/maps4fs/generator/config.py b/maps4fs/generator/config.py index 4fc42ef..a6cecb8 100644 --- a/maps4fs/generator/config.py +++ b/maps4fs/generator/config.py @@ -36,7 +36,7 @@ def _set_map_size(self) -> None: self.logger.warning("Map XML file not found: %s.", self._map_xml_path) return tree = ET.parse(self._map_xml_path) - self.logger.debug("Map XML file loaded from: %s.", self._map_xml_path) + self.logger.info("Map XML file loaded from: %s.", self._map_xml_path) root = tree.getroot() for map_elem in root.iter("map"): map_elem.set("width", str(self.map_width)) diff --git a/maps4fs/generator/dem.py b/maps4fs/generator/dem.py index 2d0b42a..1774d12 100644 --- a/maps4fs/generator/dem.py +++ b/maps4fs/generator/dem.py @@ -103,7 +103,7 @@ def process(self) -> None: north, south, east, west = self.bbox dem_output_resolution = self.get_output_resolution() - self.logger.debug("DEM output resolution: %s.", dem_output_resolution) + self.logger.info("DEM output resolution: %s.", dem_output_resolution) tile_path = self._srtm_tile() if not tile_path: @@ -223,7 +223,7 @@ def process(self) -> None: ) cv2.imwrite(self._dem_path, resampled_data) - self.logger.debug("DEM data was saved to %s.", self._dem_path) + self.logger.info("DEM data was saved to %s.", self._dem_path) if self.game.additional_dem_name is not None: self.make_copy(self.game.additional_dem_name) @@ -239,7 +239,7 @@ def make_copy(self, dem_name: str) -> None: additional_dem_path = os.path.join(dem_directory, dem_name) shutil.copyfile(self._dem_path, additional_dem_path) - self.logger.debug("Additional DEM data was copied to %s.", additional_dem_path) + self.logger.info("Additional DEM data was copied to %s.", additional_dem_path) def _tile_info(self, lat: float, lon: float) -> tuple[str, str]: """Returns latitude band and tile name for SRTM tile from coordinates. @@ -260,7 +260,7 @@ def _tile_info(self, lat: float, lon: float) -> tuple[str, str]: else: tile_name = f"{latitude_band}E{abs(tile_longitude):03d}" - self.logger.debug( + self.logger.info( "Detected tile name: %s for coordinates: lat %s, lon %s.", tile_name, lat, lon ) return latitude_band, tile_name @@ -421,14 +421,18 @@ def _normalize_dem(self, data: np.ndarray) -> np.ndarray: scaling_factor = self._get_scaling_factor(max_dev) adjusted_max_height = int(65535 * scaling_factor) - self.logger.debug( - f"Maximum deviation: {max_dev}. Scaling factor: {scaling_factor}. " - f"Adjusted max height: {adjusted_max_height}." + self.logger.info( + "Maximum deviation: %s. Scaling factor: %s. Adjusted max height: %s.", + max_dev, + scaling_factor, + adjusted_max_height, ) normalized_data = ( (data - data.min()) / (data.max() - data.min()) * adjusted_max_height ).astype("uint16") self.logger.debug( - f"DEM data was normalized to {normalized_data.min()} - {normalized_data.max()}." + "DEM data was normalized to %s - %s.", + normalized_data.min(), + normalized_data.max(), ) return normalized_data diff --git a/maps4fs/generator/grle.py b/maps4fs/generator/grle.py index bb6e3c5..e299ee6 100644 --- a/maps4fs/generator/grle.py +++ b/maps4fs/generator/grle.py @@ -61,7 +61,7 @@ def process(self) -> None: info_layer_data = np.zeros((height, width), dtype=data_type) print(info_layer_data.shape) cv2.imwrite(file_path, info_layer_data) # pylint: disable=no-member - self.logger.info("InfoLayer PNG file %s created.", file_path) + self.logger.debug("InfoLayer PNG file %s created.", file_path) else: self.logger.warning("Invalid InfoLayer schema: %s.", info_layer) diff --git a/maps4fs/generator/i3d.py b/maps4fs/generator/i3d.py index 4f9b41b..c06c7ec 100644 --- a/maps4fs/generator/i3d.py +++ b/maps4fs/generator/i3d.py @@ -89,7 +89,7 @@ def _update_i3d_file(self) -> None: self.logger.debug("TerrainTransformGroup element updated in I3D file.") tree.write(self._map_i3d_path) # type: ignore - self.logger.debug("Map I3D file saved to: %s.", self._map_i3d_path) + self.logger.info("Map I3D file saved to: %s.", self._map_i3d_path) def previews(self) -> list[str]: """Returns a list of paths to the preview images (empty list). @@ -120,13 +120,11 @@ def _add_fields(self) -> None: self.logger.warning("Fields data not found in textures info layer.") return - self.logger.debug("Found %s fields in textures info layer.", len(fields)) + self.logger.info("Found %s fields in textures info layer.", len(fields)) root = tree.getroot() gameplay_node = root.find(".//TransformGroup[@name='gameplay']") if gameplay_node is not None: - self.logger.debug("Found the gameplay node.") - fields_node = gameplay_node.find(".//TransformGroup[@name='fields']") user_attributes_node = root.find(".//UserAttributes") @@ -194,7 +192,7 @@ def _add_fields(self) -> None: node_id += 1 tree.write(self._map_i3d_path) # type: ignore - self.logger.debug("Map I3D file saved to: %s.", self._map_i3d_path) + self.logger.info("Map I3D file saved to: %s.", self._map_i3d_path) def get_name_indicator_node(self, node_id: int, field_id: int) -> tuple[ET.Element, int]: """Creates a name indicator node with given node ID and field ID. diff --git a/maps4fs/generator/map.py b/maps4fs/generator/map.py index ae62e70..b3a47cd 100644 --- a/maps4fs/generator/map.py +++ b/maps4fs/generator/map.py @@ -44,17 +44,17 @@ def __init__( # pylint: disable=R0917 if not logger: logger = Logger(to_stdout=True, to_file=False) self.logger = logger - self.logger.debug("Game was set to %s", game.code) + self.logger.info("Game was set to %s", game.code) self.kwargs = kwargs - self.logger.debug("Additional arguments: %s", kwargs) + self.logger.info("Additional arguments: %s", kwargs) os.makedirs(self.map_directory, exist_ok=True) self.logger.debug("Map directory created: %s", self.map_directory) try: shutil.unpack_archive(game.template_path, self.map_directory) - self.logger.info("Map template unpacked to %s", self.map_directory) + self.logger.debug("Map template unpacked to %s", self.map_directory) except Exception as e: raise RuntimeError(f"Can not unpack map template due to error: {e}") from e diff --git a/maps4fs/generator/texture.py b/maps4fs/generator/texture.py index 694b87d..524c855 100644 --- a/maps4fs/generator/texture.py +++ b/maps4fs/generator/texture.py @@ -239,7 +239,7 @@ def _prepare_weights(self): for layer in self.layers: self._generate_weights(layer) - self.logger.debug("Prepared weights for %s layers.", len(self.layers)) + self.logger.info("Prepared weights for %s layers.", len(self.layers)) def _generate_weights(self, layer: Layer) -> None: """Generates weight files for textures. Each file is a numpy array of zeros and @@ -339,7 +339,7 @@ def draw(self) -> None: cumulative_image = cv2.bitwise_or(cumulative_image, output_image) cv2.imwrite(layer_path, output_image) - self.logger.debug("Texture %s saved.", layer_path) + self.logger.info("Texture %s saved.", layer_path) # Save info layer data. with open(self.info_layer_path, "w", encoding="utf-8") as f: @@ -351,7 +351,7 @@ def draw(self) -> None: if not self.light_version: self.dissolve() else: - self.logger.info("Skipping dissolve in light version of the map.") + self.logger.debug("Skipping dissolve in light version of the map.") def dissolve(self) -> None: """Dissolves textures of the layers with tags into sublayers for them to look more @@ -423,7 +423,7 @@ def draw_base_layer(self, cumulative_image: np.ndarray) -> None: self.logger.debug("Drawing base layer %s.", layer_path) img = cv2.bitwise_not(cumulative_image) cv2.imwrite(layer_path, img) - self.logger.debug("Base texture %s saved.", layer_path) + self.logger.info("Base texture %s saved.", layer_path) def get_relative_x(self, x: float) -> int: """Converts UTM X coordinate to relative X coordinate in map image. diff --git a/webui/config.py b/webui/config.py index 58b74e1..949456f 100644 --- a/webui/config.py +++ b/webui/config.py @@ -70,13 +70,13 @@ def remove_with_delay_without_blocking( """ def remove_file() -> None: - logger.info("Removing file from %s in %s seconds.", file_path, delay) + logger.debug("Removing file from %s in %s seconds.", file_path, delay) sleep(delay) try: os.remove(file_path) logger.info("File %s removed.", file_path) except FileNotFoundError: - logger.warning("File %s not found.", file_path) + logger.debug("File %s not found.", file_path) logger.debug("Starting a new thread to remove the file %s.", file_path) threading.Thread(target=remove_file).start() diff --git a/webui/generator.py b/webui/generator.py index 55afbcf..938865e 100644 --- a/webui/generator.py +++ b/webui/generator.py @@ -44,10 +44,10 @@ class GeneratorUI: def __init__(self): self.download_path = None - self.logger = mfs.Logger(level="DEBUG", to_file=False) + self.logger = mfs.Logger(level="INFO", to_file=False) self.community = config.is_on_community_server() - self.logger.info("The application launched on the community server: %s", self.community) + self.logger.debug("The application launched on the community server: %s", self.community) self.left_column, self.right_column = st.columns(2, gap="large") @@ -94,7 +94,7 @@ def map_preview(self) -> None: except ValueError: return - self.logger.info( + self.logger.debug( "Generating map preview for lat=%s, lon=%s, map_size=%s", lat, lon, map_size ) @@ -106,14 +106,14 @@ def map_preview(self) -> None: def add_right_widgets(self) -> None: """Add widgets to the right column.""" - self.logger.info("Adding widgets to the right column...") + self.logger.debug("Adding widgets to the right column...") self.html_preview_container = st.empty() self.map_selector_container = st.container() self.preview_container = st.container() def add_left_widgets(self) -> None: """Add widgets to the left column.""" - self.logger.info("Adding widgets to the left column...") + self.logger.debug("Adding widgets to the left column...") st.title(Messages.TITLE) st.write(Messages.MAIN_PAGE_DESCRIPTION) @@ -158,7 +158,7 @@ def add_left_widgets(self) -> None: ) if self.map_size_input == "Custom": - self.logger.info("Custom map size selected.") + self.logger.debug("Custom map size selected.") st.info("ℹ️ Map size can be only a power of 2. For example: 2, 4, ... 2048, 4096, ...") st.warning("⚠️ Large map sizes can crash on generation or import in the game.") @@ -209,7 +209,7 @@ def add_left_widgets(self) -> None: ) if self.advanced_settings: - self.logger.info("Advanced settings are enabled.") + self.logger.debug("Advanced settings are enabled.") st.warning("⚠️ Changing these settings can lead to unexpected results.") st.info( @@ -267,7 +267,7 @@ def add_left_widgets(self) -> None: # Download button. if st.session_state.generated: - self.logger.info("Generated was set to True in the session state.") + self.logger.debug("Generated was set to True in the session state.") with open(self.download_path, "rb") as f: with self.buttons_container: st.download_button( @@ -282,7 +282,7 @@ def add_left_widgets(self) -> None: config.remove_with_delay_without_blocking(self.download_path, self.logger) st.session_state.generated = False - self.logger.info("Generated was set to False in the session state.") + self.logger.debug("Generated was set to False in the session state.") def get_sesion_name(self, coordinates: tuple[float, float]) -> str: """Return a session name for the map, using the coordinates and the current timestamp.