You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/09/14 08:08:20 UTC

[incubator-nlpcraft] branch NLPCRAFT-41 updated: Fixing error log.

This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-41
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-41 by this push:
     new 988f600  Fixing error log.
988f600 is described below

commit 988f600d2d7485a0444163501cfbf46633ce4850
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Mon Sep 14 01:08:09 2020 -0700

    Fixing error log.
---
 .../src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala | 4 ++--
 .../org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala    | 6 +++---
 .../apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala    | 2 +-
 .../nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala       | 2 +-
 .../org/apache/nlpcraft/server/company/NCCompanyManager.scala    | 6 +++++-
 .../org/apache/nlpcraft/server/ignite/NCIgniteExceptions.scala   | 2 +-
 .../scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala  | 9 +++++++--
 .../scala/org/apache/nlpcraft/server/query/NCQueryManager.scala  | 2 +-
 .../scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala   | 4 ++--
 9 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
index 859a977..8536f8d 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
@@ -491,7 +491,7 @@ object NCUtils extends LazyLogging {
                         logger.debug(s"Timer task executed [name=$name, execution-time=${System.currentTimeMillis() - now}]")
                     }
                     catch {
-                        case e: Throwable ⇒ logger.error(s"Error executing daily timer [name=$name]", e)
+                        case e: Throwable ⇒ prettyError(logger, s"Error executing daily '$name' timer:", e)
                     }
                 }
             },
@@ -903,7 +903,7 @@ object NCUtils extends LazyLogging {
                 }
                 catch {
                     case _: InterruptedException ⇒ logger.trace(s"Thread interrupted: $name")
-                    case e: Throwable ⇒ logger.error(s"Unexpected error during thread execution: $name", e)
+                    case e: Throwable ⇒ prettyError(logger, s"Unexpected error during '$name' thread execution:", e)
                 }
                 finally
                     stopped = true
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
index c8ffc5c..e2cc9d1 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
@@ -23,7 +23,7 @@ import java.util.concurrent.{ExecutorService, Executors}
 import com.google.gson.Gson
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.common.nlp.NCNlpSentence
-import org.apache.nlpcraft.common.util.NCUtils
+import org.apache.nlpcraft.common._
 import org.apache.nlpcraft.common.NCService
 import org.apache.nlpcraft.model.NCToken
 import org.apache.nlpcraft.probe.mgrs.NCProbeMessage
@@ -55,7 +55,7 @@ object NCCommandManager extends NCService {
     override def stop(parent: Span = null): Unit = startScopedSpan("stop", parent) { _ ⇒
         super.stop()
 
-        NCUtils.shutdownPools(pool)
+        U.shutdownPools(pool)
 
         executor = null
         pool = null
@@ -133,7 +133,7 @@ object NCCommandManager extends NCService {
                         logger.error(s"Received unknown server message (you need to update the probe): ${msg.getType}")
                 }
             catch {
-                case e: Throwable ⇒ logger.error(s"Error while processing server message (ignoring): ${msg.getType}", e)
+                case e: Throwable ⇒ U.prettyError(logger, s"Error while processing server message (ignoring): ${msg.getType}", e)
             }
         }
 }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
index 529c2b5..7c6938f 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
@@ -339,7 +339,7 @@ object NCConnectionManager extends NCService {
                       */
                     def exit(caller: Thread, msg: String, cause: Exception = null): Unit = {
                         if (cause != null)
-                            logger.error(msg, cause)
+                            U.prettyError(logger, msg, cause)
                         else
                             logger.error(msg)
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
index 76efd7a..5e944d1 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
@@ -662,7 +662,7 @@ object NCProbeEnrichmentManager extends NCService with NCOpenCensusModelStats {
                             "errMsg" → e.getMessage
                         )
                     
-                        logger.error(s"Unexpected error for server request ID: $srvReqId", e)
+                        U.prettyError(logger,s"Unexpected error for server request ID: $srvReqId", e)
         
                         val res = mdl.model.onError(ctx, e)
         
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/company/NCCompanyManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/company/NCCompanyManager.scala
index b480b72..66d41f3 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/company/NCCompanyManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/company/NCCompanyManager.scala
@@ -93,7 +93,11 @@ object NCCompanyManager extends NCService with NCIgniteInstance {
                     logger.info(s"Default admin user ($adminEmail/$adminPwd) created for default company: $compName")
                 }
                 catch {
-                    case e: NCE ⇒ logger.error(s"Failed to add default admin user: ${e.getLocalizedMessage}", e)
+                    case e: NCE ⇒ U.prettyError(
+                        logger,
+                        s"Failed to add default admin user: ${e.getLocalizedMessage}",
+                        e
+                    )
                 }
         }
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/ignite/NCIgniteExceptions.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/ignite/NCIgniteExceptions.scala
index 34b70fc..5cfa02f 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/ignite/NCIgniteExceptions.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/ignite/NCIgniteExceptions.scala
@@ -57,6 +57,6 @@ trait NCIgniteExceptions {
       * @return Catcher.
       */
     protected def logIE(logger: Logger): Catcher[Unit] = {
-        case e: IgniteException ⇒ logger.error(s"Ignite error.", e)
+        case e: IgniteException ⇒ U.prettyError(logger, s"Ignite error.", e)
     }
 }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
index 20bf78b..21f225b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
@@ -352,7 +352,12 @@ object NCProbeManager extends NCService {
                 }
                 catch {
                     case _: InterruptedException ⇒ logger.trace(s"Thread interrupted: $thName")
-                    case e: Throwable ⇒ logger.error(s"Unexpected error during thread execution: $thName", e)
+                    case e: Throwable ⇒
+                        U.prettyError(
+                            logger,
+                            s"Unexpected error during '$thName' thread execution:",
+                            e
+                        )
                 }
                 finally
                     stopped = true
@@ -758,7 +763,7 @@ object NCProbeManager extends NCService {
                     }
                     catch {
                         case e: Throwable ⇒
-                            logger.error(s"Failed to process probe message: $typ", e)
+                            U.prettyError(logger,s"Failed to process probe message: $typ", e)
         
                             NCQueryManager.setError(
                                 srvReqId,
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala
index c92d2a4..696b478 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/query/NCQueryManager.scala
@@ -291,7 +291,7 @@ object NCQueryManager extends NCService with NCIgniteInstance with NCOpenCensusS
                 )
 
             case Failure(e: Throwable) ⇒
-                logger.error(s"System error processing query: ${e.getLocalizedMessage}", e)
+                U.prettyError(logger,s"System error processing query: ${e.getLocalizedMessage}", e)
 
                 setError(
                     srvReqId,
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
index b7b83c9..d53ce72 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
@@ -573,7 +573,7 @@ class NCBasicRestApi extends NCRestApi with LazyLogging with NCOpenCensusTrace w
 
                     StatusCodes.BadRequest
                 case _ ⇒
-                    logger.error(s"Unexpected system error: $errMsg", e)
+                    U.prettyError(logger,s"Unexpected system error: $errMsg", e)
 
                     StatusCodes.InternalServerError
             }
@@ -1816,7 +1816,7 @@ class NCBasicRestApi extends NCRestApi with LazyLogging with NCOpenCensusTrace w
             val errMsg = e.getLocalizedMessage
             val code = "NC_ERROR"
 
-            logger.error(s"Unexpected system error: $errMsg", e)
+            U.prettyError(logger,s"Unexpected system error: $errMsg", e)
 
             completeError(StatusCodes.InternalServerError, code, errMsg)
     }