This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/sedona-db.git
The following commit(s) were added to refs/heads/main by this push:
new 0d9a7c8 Default proj log level to none (#77)
0d9a7c8 is described below
commit 0d9a7c877e2bfa7b2a100ece7643c2655353d6b0
Author: jp <[email protected]>
AuthorDate: Sat Sep 13 21:03:11 2025 -0700
Default proj log level to none (#77)
---
c/sedona-proj/src/proj.rs | 15 +++++++++++++++
c/sedona-proj/src/transform.rs | 32 +++++++++++++++++++++++++++++---
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/c/sedona-proj/src/proj.rs b/c/sedona-proj/src/proj.rs
index c57af59..2695706 100644
--- a/c/sedona-proj/src/proj.rs
+++ b/c/sedona-proj/src/proj.rs
@@ -130,6 +130,21 @@ impl ProjContext {
}
}
+ /// Set the logging level for PROJ operations
+ ///
+ /// `level` - Unsigned Integer value representing the log level:
+ /// - PJ_LOG_LEVEL_PJ_LOG_NONE (0): No logging
+ /// - PJ_LOG_LEVEL_PJ_LOG_ERROR (1): Error messages
+ /// - PJ_LOG_LEVEL_PJ_LOG_DEBUG (2): Debug messages
+ /// - PJ_LOG_LEVEL_PJ_LOG_TRACE (3): Trace
+ /// - PJ_LOG_LEVEL_PJ_LOG_TELL (4): Tell
+ pub(crate) fn set_log_level(&self, level: u32) -> Result<(),
SedonaProjError> {
+ unsafe {
+ call_proj_api!(self.api, proj_log_level, self.inner, level);
+ }
+ Ok(())
+ }
+
/// Set the path in which to look for PROJ data files
///
/// Most PROJ distributions come with a few small data files installed to
a /share directory
diff --git a/c/sedona-proj/src/transform.rs b/c/sedona-proj/src/transform.rs
index f3bb451..3ed71cb 100644
--- a/c/sedona-proj/src/transform.rs
+++ b/c/sedona-proj/src/transform.rs
@@ -14,6 +14,8 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+use crate::error::SedonaProjError;
+use crate::proj::{Proj, ProjContext};
use sedona_geometry::bounding_box::BoundingBox;
use sedona_geometry::error::SedonaGeometryError;
use sedona_geometry::interval::IntervalTrait;
@@ -22,9 +24,6 @@ use std::cell::RefCell;
use std::path::PathBuf;
use std::rc::Rc;
-use crate::error::SedonaProjError;
-use crate::proj::{Proj, ProjContext};
-
/// Builder for a [ProjCrsEngine]
///
/// API for specifying various engine parameters. More parameters may
@@ -34,6 +33,7 @@ pub struct ProjCrsEngineBuilder {
shared_library: Option<PathBuf>,
database_path: Option<PathBuf>,
search_paths: Option<Vec<PathBuf>>,
+ log_level: Option<u32>,
}
impl ProjCrsEngineBuilder {
@@ -82,6 +82,25 @@ impl ProjCrsEngineBuilder {
}
}
+ /// Set the PROJ log level
+ ///
+ /// Set the verbosity of PROJ logging. The default is no logging,
+ /// however errors will still be propagated through the error
+ /// handling.
+ ///
+ /// Log level constants are defined in proj_sys:
+ /// - PJ_LOG_LEVEL_PJ_LOG_NONE (0): No logging
+ /// - PJ_LOG_LEVEL_PJ_LOG_ERROR (1): Error messages
+ /// - PJ_LOG_LEVEL_PJ_LOG_DEBUG (2): Debug messages
+ /// - PJ_LOG_LEVEL_PJ_LOG_TRACE (3): Trace
+ /// - PJ_LOG_LEVEL_PJ_LOG_TELL (4): Tell
+ pub fn with_log_level(self, log_level: u32) -> Self {
+ Self {
+ log_level: Some(log_level),
+ ..self
+ }
+ }
+
/// Build a [ProjCrsEngine] with the specified options
pub fn build(&self) -> Result<ProjCrsEngine, SedonaProjError> {
let mut ctx = if let Some(shared_library) =
self.shared_library.clone() {
@@ -102,6 +121,13 @@ impl ProjCrsEngineBuilder {
ctx.set_search_paths(&string_vec)?;
}
+ if let Some(log_level) = &self.log_level {
+ ctx.set_log_level(*log_level)?;
+ } else {
+ // Default log level to none
+ ctx.set_log_level(0)?;
+ }
+
Ok(ProjCrsEngine { ctx: Rc::new(ctx) })
}
}