mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Fix log vs tracing annotations
This commit is contained in:
parent
f0af2f9350
commit
56ab38b29e
@ -73,6 +73,7 @@ tracing-subscriber = { version = "0.3", optional = true }
|
||||
tracing-tracy = { version = "0.8", optional = true }
|
||||
tracy-client = { git = "https://github.com/nagisa/rust_tracy_client.git", branch = "create-pull-request/patch", optional = true }
|
||||
|
||||
|
||||
# Vector riles
|
||||
vector-tile = { path = "./libs/vector_tile" }
|
||||
style-spec = { path = "./libs/style_spec" }
|
||||
|
||||
@ -4,7 +4,6 @@ use crate::Scheduler;
|
||||
use cgmath::Vector2;
|
||||
|
||||
use crate::coords::WorldCoords;
|
||||
use log::info;
|
||||
use std::time::Duration;
|
||||
use winit::event::{ElementState, MouseButton};
|
||||
|
||||
@ -82,7 +81,7 @@ impl QueryHandler {
|
||||
z,
|
||||
zoom,
|
||||
) {
|
||||
info!(
|
||||
log::info!(
|
||||
"{:?}",
|
||||
geometries
|
||||
.iter()
|
||||
|
||||
@ -47,6 +47,7 @@ pub enum TessellateMessage {
|
||||
|
||||
pub struct TileTessellateMessage {
|
||||
request_id: TileRequestID,
|
||||
coords: WorldTileCoords,
|
||||
}
|
||||
|
||||
pub enum LayerTessellateMessage {
|
||||
|
||||
@ -3,7 +3,6 @@ use std::future::Future;
|
||||
|
||||
use geozero::mvt::Tile;
|
||||
use geozero::GeozeroDatasource;
|
||||
use log::{error, info};
|
||||
use std::sync::mpsc::{channel, Receiver, SendError, Sender};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
@ -86,17 +85,6 @@ pub struct ThreadLocalState {
|
||||
geometry_index: Arc<Mutex<GeometryIndex>>,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
impl Drop for ThreadLocalState {
|
||||
fn drop(&mut self) {
|
||||
use log::warn;
|
||||
warn!(
|
||||
"ThreadLocalTessellatorState dropped. \
|
||||
On web this should only happen when the application is stopped!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl ThreadLocalState {
|
||||
fn get_tile_request(&self, request_id: TileRequestID) -> Option<TileRequest> {
|
||||
self.tile_request_state
|
||||
@ -194,6 +182,7 @@ impl ThreadLocalState {
|
||||
match tile_result {
|
||||
TileFetchResult::Unavailable { coords } => {
|
||||
for to_load in &tile_request.layers {
|
||||
tracing::warn!("layer {} at {} unavailable", to_load, &coords);
|
||||
self.tessellate_result_sender
|
||||
.send(TessellateMessage::Layer(
|
||||
LayerTessellateMessage::UnavailableLayer {
|
||||
@ -204,7 +193,7 @@ impl ThreadLocalState {
|
||||
}
|
||||
}
|
||||
TileFetchResult::Tile { data, coords } => {
|
||||
info!("parsing tile {} with {}bytes", &coords, data.len());
|
||||
tracing::info!("parsing tile {} with {}bytes", &coords, data.len());
|
||||
|
||||
let tile = {
|
||||
let _span_ =
|
||||
@ -220,6 +209,7 @@ impl ThreadLocalState {
|
||||
{
|
||||
match layer.tessellate() {
|
||||
Ok((buffer, feature_indices)) => {
|
||||
tracing::info!("layer {} at {} ready", to_load, &coords);
|
||||
self.tessellate_result_sender
|
||||
.send(TessellateMessage::Layer(
|
||||
LayerTessellateMessage::TessellatedLayer {
|
||||
@ -239,14 +229,14 @@ impl ThreadLocalState {
|
||||
},
|
||||
))?;
|
||||
|
||||
error!(
|
||||
"tesselation for layer {} failed: {} {:?}",
|
||||
to_load, &coords, e
|
||||
tracing::error!(
|
||||
"layer {} at {} tesselation failed {:?}",
|
||||
to_load,
|
||||
&coords,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
info!("layer {} ready: {}", to_load, &coords);
|
||||
} else {
|
||||
self.tessellate_result_sender
|
||||
.send(TessellateMessage::Layer(
|
||||
@ -256,15 +246,22 @@ impl ThreadLocalState {
|
||||
},
|
||||
))?;
|
||||
|
||||
info!("layer {} not found: {}", to_load, &coords);
|
||||
tracing::info!(
|
||||
"requested layer {} at {} not found in tile",
|
||||
to_load,
|
||||
&coords
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tracing::info!("tile at {} finished", &coords);
|
||||
|
||||
self.tessellate_result_sender
|
||||
.send(TessellateMessage::Tile(TileTessellateMessage {
|
||||
request_id,
|
||||
coords: tile_request.coords,
|
||||
}))?;
|
||||
|
||||
Ok(())
|
||||
@ -300,16 +297,23 @@ impl Scheduler {
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub fn try_populate_cache(&mut self) {
|
||||
if let Ok(mut tile_request_state) = self.tile_request_state.try_lock() {
|
||||
if let Ok(result) = self.tessellate_channel.1.try_recv() {
|
||||
match result {
|
||||
TessellateMessage::Layer(layer_result) => {
|
||||
self.tile_cache.put_tessellated_layer(layer_result);
|
||||
}
|
||||
TessellateMessage::Tile(TileTessellateMessage { request_id }) => {
|
||||
tile_request_state.finish_tile_request(request_id);
|
||||
}
|
||||
if let Ok(result) = self.tessellate_channel.1.try_recv() {
|
||||
match result {
|
||||
TessellateMessage::Layer(layer_result) => {
|
||||
tracing::trace!(
|
||||
"Layer {} at {} reached main thread",
|
||||
layer_result.layer_name(),
|
||||
layer_result.get_coords()
|
||||
);
|
||||
self.tile_cache.put_tessellated_layer(layer_result);
|
||||
}
|
||||
TessellateMessage::Tile(TileTessellateMessage { request_id, coords }) => loop {
|
||||
if let Ok(mut tile_request_state) = self.tile_request_state.try_lock() {
|
||||
tile_request_state.finish_tile_request(request_id);
|
||||
tracing::trace!("Tile at {} finished loading", coords);
|
||||
break;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -336,7 +340,7 @@ impl Scheduler {
|
||||
coords: *coords,
|
||||
layers: layers.clone(),
|
||||
}) {
|
||||
info!("new tile request: {}", &coords);
|
||||
tracing::info!("new tile request: {}", &coords);
|
||||
|
||||
// The following snippet can be added instead of the next code block to demonstrate
|
||||
// an understanable approach of fetching
|
||||
|
||||
@ -2,7 +2,6 @@ use std::concat;
|
||||
use std::env;
|
||||
|
||||
use include_dir::Dir;
|
||||
use log::error;
|
||||
|
||||
use crate::coords::TileCoords;
|
||||
use crate::error::Error;
|
||||
@ -32,7 +31,7 @@ impl StaticTileFetcher {
|
||||
|
||||
pub fn sync_fetch_tile(&self, coords: &TileCoords) -> Result<Vec<u8>, Error> {
|
||||
if TILES.entries().is_empty() {
|
||||
error!(
|
||||
log::error!(
|
||||
"There are not tiles statically embedded in this binary! StaticTileFetcher will \
|
||||
not return any tiles!"
|
||||
)
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
//! * Platform Events like suspend/resume
|
||||
//! * Render a new frame
|
||||
|
||||
use log::{error, info, trace};
|
||||
use style_spec::Style;
|
||||
use winit::event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent};
|
||||
use winit::event_loop::{ControlFlow, EventLoop};
|
||||
@ -21,7 +20,7 @@ pub async fn run(
|
||||
style: Box<Style>,
|
||||
max_frames: Option<u64>,
|
||||
) {
|
||||
let root = tracing::span!(tracing::Level::TRACE, "app_start", work_units = 2);
|
||||
let root = tracing::span!(tracing::Level::TRACE, "app_start");
|
||||
let _enter = root.enter();
|
||||
|
||||
let mut input = InputController::new(0.2, 100.0, 0.1);
|
||||
@ -62,7 +61,6 @@ pub async fn run(
|
||||
ref event,
|
||||
.. // We're not using device_id currently
|
||||
} => {
|
||||
trace!("{:?}", event);
|
||||
input.device_input(event);
|
||||
}
|
||||
|
||||
@ -107,11 +105,11 @@ pub async fn run(
|
||||
match state.render() {
|
||||
Ok(_) => {}
|
||||
Err(wgpu::SurfaceError::Lost) => {
|
||||
error!("Surface Lost");
|
||||
log::error!("Surface Lost");
|
||||
},
|
||||
// The system is out of memory, we should probably quit
|
||||
Err(wgpu::SurfaceError::OutOfMemory) => {
|
||||
error!("Out of Memory");
|
||||
log::error!("Out of Memory");
|
||||
*control_flow = ControlFlow::Exit;
|
||||
},
|
||||
// All other errors (Outdated, Timeout) should be resolved by the next frame
|
||||
@ -122,7 +120,7 @@ pub async fn run(
|
||||
|
||||
if let Some(max_frames) = max_frames {
|
||||
if current_frame >= max_frames {
|
||||
info!("Exiting because maximum frames reached.");
|
||||
log::info!("Exiting because maximum frames reached.");
|
||||
*control_flow = ControlFlow::Exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
use std::thread::Thread;
|
||||
|
||||
use log::warn;
|
||||
|
||||
use js_sys::{ArrayBuffer, Error as JSError, Uint8Array};
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
use std::panic;
|
||||
use std::thread::Thread;
|
||||
|
||||
use log::error;
|
||||
use log::info;
|
||||
use log::warn;
|
||||
use log::Level;
|
||||
use winit::dpi::LogicalSize;
|
||||
use winit::event_loop::EventLoop;
|
||||
use winit::platform::web::WindowBuilderExtWebSys;
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
use std::panic;
|
||||
|
||||
use log::error;
|
||||
use log::info;
|
||||
use log::Level;
|
||||
use winit::dpi::LogicalSize;
|
||||
use winit::event_loop::EventLoop;
|
||||
use winit::platform::web::WindowBuilderExtWebSys;
|
||||
|
||||
@ -6,8 +6,6 @@ use std::cell::RefCell;
|
||||
use std::future::Future;
|
||||
use std::rc::Rc;
|
||||
|
||||
use log::{info, warn};
|
||||
|
||||
use js_sys::Promise;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
use std::thread::Thread;
|
||||
|
||||
use log::warn;
|
||||
|
||||
use js_sys::{ArrayBuffer, Error as JSError, Uint8Array};
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
|
||||
@ -85,6 +85,7 @@ impl RenderState {
|
||||
};
|
||||
|
||||
// create an instance
|
||||
//let instance = wgpu::Instance::new(wgpu::Backends::GL);
|
||||
let instance = wgpu::Instance::new(wgpu::Backends::all());
|
||||
|
||||
// create an surface
|
||||
@ -249,8 +250,7 @@ impl RenderState {
|
||||
|
||||
surface.configure(&device, &surface_config);
|
||||
|
||||
let depth_texture =
|
||||
Texture::create_depth_texture(&device, &surface_config, "depth_texture", sample_count);
|
||||
let depth_texture = Texture::create_depth_texture(&device, &surface_config, sample_count);
|
||||
|
||||
let multisampling_texture = if sample_count > 1 {
|
||||
Some(Texture::create_multisampling_texture(
|
||||
@ -339,7 +339,6 @@ impl RenderState {
|
||||
self.depth_texture = Texture::create_depth_texture(
|
||||
&self.device,
|
||||
&self.surface_config,
|
||||
"depth_texture",
|
||||
self.sample_count,
|
||||
);
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@ impl Texture {
|
||||
pub fn create_depth_texture(
|
||||
device: &wgpu::Device,
|
||||
config: &wgpu::SurfaceConfiguration,
|
||||
_label: &str,
|
||||
sample_count: u32,
|
||||
) -> Self {
|
||||
let depth_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use log::info;
|
||||
|
||||
use crate::platform::Instant;
|
||||
|
||||
/// Measures the frames per second.
|
||||
@ -33,7 +31,7 @@ impl FPSMeter {
|
||||
self.frame_count += 1;
|
||||
let now = Instant::now();
|
||||
if now >= self.next_report {
|
||||
info!("{} FPS", self.frame_count);
|
||||
log::info!("{} FPS", self.frame_count);
|
||||
self.frame_count = 0;
|
||||
self.next_report = now + Duration::from_secs(1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user