diff --git a/core/src/main/scala/io/pdal/LogLevel.scala b/core/src/main/scala/io/pdal/LogLevel.scala index 7edaf61..888693e 100644 --- a/core/src/main/scala/io/pdal/LogLevel.scala +++ b/core/src/main/scala/io/pdal/LogLevel.scala @@ -24,15 +24,6 @@ package io.pdal -object LogLevel { - val Error = 0 - val Warning = 1 - val Info = 2 - val Debug = 3 - val Debug1 = 4 - val Debug2 = 5 - val Debug3 = 6 - val Debug4 = 7 - val Debug5 = 8 - val None = 9 +object LogLevel extends Enumeration { + val Error, Warning, Info, Debug, Debug1, Debug2, Debug3, Debug4, Debug5 = Value } diff --git a/core/src/main/scala/io/pdal/Pipeline.scala b/core/src/main/scala/io/pdal/Pipeline.scala index c349887..e38a81e 100644 --- a/core/src/main/scala/io/pdal/Pipeline.scala +++ b/core/src/main/scala/io/pdal/Pipeline.scala @@ -26,9 +26,11 @@ package io.pdal import com.github.sbt.jni.syntax.NativeLoader -class Pipeline(val json: String, val logLevel: Int) extends Native { +class Pipeline private (val json: String, val logLevel: Int) extends Native { Pipeline // reference the object so that the nativeLoader will load the JNI native libraries + def this(json: String, logLevel: LogLevel.Value = LogLevel.Error) = this(json, logLevel.id) + @native def initialize(): Unit @native def execute(): Unit @native def getPointViews(): PointViewIterator @@ -41,11 +43,10 @@ class Pipeline(val json: String, val logLevel: Int) extends Native { @native def validate(): Boolean @native def setLogLevel(i: Int): Unit @native def getLogLevel(): Int - @native def getLog(): String } object Pipeline extends NativeLoader("pdaljni.2.6") { - def apply(json: String, logLevel: Int = LogLevel.Error): Pipeline = { + def apply(json: String, logLevel: LogLevel.Value = LogLevel.Error): Pipeline = { val p = new Pipeline(json, logLevel); p.initialize(); p } } diff --git a/native/src/JavaPipeline.cpp b/native/src/JavaPipeline.cpp index 4e645f3..6953b92 100644 --- a/native/src/JavaPipeline.cpp +++ b/native/src/JavaPipeline.cpp @@ -36,8 +36,6 @@ #include #endif -using pdal::LogLevel; -using pdal::LogPtr; using pdal::MetadataNode; using pdal::PointId; using pdal::PointViewSet; @@ -64,14 +62,9 @@ PipelineExecutor::PipelineExecutor(string const& json, int level) { setLogLevel(level); - LogPtr log(pdal::Log::makeLog("javapipeline", &m_logStream)); - log->setLevel(m_logLevel); - m_manager.setLog(log); - stringstream strm; strm << json; m_manager.readPipeline(strm); - } bool PipelineExecutor::validate() @@ -123,7 +116,6 @@ string PipelineExecutor::getPipeline() const return strm.str(); } - string PipelineExecutor::getMetadata() const { if (!m_executed) @@ -135,7 +127,6 @@ string PipelineExecutor::getMetadata() const return strm.str(); } - string PipelineExecutor::getSchema() const { if (!m_executed) @@ -188,7 +179,6 @@ MetadataNode computePreview(Stage* stage) return summary; } - string PipelineExecutor::getQuickInfo() const { @@ -217,25 +207,18 @@ string PipelineExecutor::getQuickInfo() const return strm.str(); } -void PipelineExecutor::setLogStream(std::ostream& strm) -{ - - LogPtr log(pdal::Log::makeLog("javapipeline", &strm)); - log->setLevel(m_logLevel); - m_manager.setLog(log); -} - - void PipelineExecutor::setLogLevel(int level) { - if (level < static_cast(LogLevel::Error) || level > static_cast(LogLevel::None)) - throw java_error("LogLevel should be between 0 and 9"); + if (level < 0 || level > 8) + throw java_error("LogLevel should be between 0 and 8!"); m_logLevel = static_cast(level); - setLogStream(m_logStream); + + pdal::LogPtr log(pdal::Log::makeLog("javapipeline", "stdlog")); + log->setLevel(m_logLevel); + m_manager.setLog(log); } - int PipelineExecutor::getLogLevel() const { return static_cast(m_logLevel); diff --git a/native/src/include/JavaPipeline.hpp b/native/src/include/JavaPipeline.hpp index 4ede172..5347243 100644 --- a/native/src/include/JavaPipeline.hpp +++ b/native/src/include/JavaPipeline.hpp @@ -75,7 +75,6 @@ class PDAL_DLL PipelineExecutor { pdal::PipelineManager const& getManager() const { return m_manager; } void setLogLevel(int level); int getLogLevel() const; - std::string getLog() const { return m_logStream.str(); } protected: virtual pdal::ConstPointTableRef pointTable() const { return m_manager.pointTable(); } @@ -84,8 +83,6 @@ class PDAL_DLL PipelineExecutor { bool m_executed = false; private: - void setLogStream(std::ostream& strm); - std::stringstream m_logStream; pdal::LogLevel m_logLevel; }; diff --git a/native/src/include/io_pdal_Pipeline.h b/native/src/include/io_pdal_Pipeline.h index 660feac..88213b0 100644 --- a/native/src/include/io_pdal_Pipeline.h +++ b/native/src/include/io_pdal_Pipeline.h @@ -103,14 +103,6 @@ JNIEXPORT void JNICALL Java_io_pdal_Pipeline_setLogLevel JNIEXPORT jint JNICALL Java_io_pdal_Pipeline_getLogLevel (JNIEnv *, jobject); -/* - * Class: io_pdal_Pipeline - * Method: getLog - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_io_pdal_Pipeline_getLog - (JNIEnv *, jobject); - #ifdef __cplusplus } #endif diff --git a/native/src/io_pdal_Pipeline.cpp b/native/src/io_pdal_Pipeline.cpp index 0138b50..2cd34b5 100644 --- a/native/src/io_pdal_Pipeline.cpp +++ b/native/src/io_pdal_Pipeline.cpp @@ -205,13 +205,6 @@ JNIEXPORT jint JNICALL Java_io_pdal_Pipeline_getLogLevel return p->getLogLevel(); } -JNIEXPORT jstring JNICALL Java_io_pdal_Pipeline_getLog - (JNIEnv *env, jobject obj) -{ - PipelineExecutor *p = getHandle(env, obj); - return env->NewStringUTF(p->getLog().c_str()); -} - JNIEXPORT jobject JNICALL Java_io_pdal_Pipeline_getPointViews (JNIEnv *env, jobject obj) {