From 50e8c72904c01c9f10c436e2c65a994382642d72 Mon Sep 17 00:00:00 2001
From: Giovanni La Mura <giovanni.lamura@inaf.it>
Date: Wed, 13 Mar 2024 14:49:37 +0100
Subject: [PATCH] Include logger in compilation.

---
 src/include/logging.h   | 15 +++++++++++++--
 src/libnptm/Makefile    |  6 +++---
 src/libnptm/logging.cpp |  8 ++++++--
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/include/logging.h b/src/include/logging.h
index 002e530a..69a3b40b 100644
--- a/src/include/logging.h
+++ b/src/include/logging.h
@@ -39,9 +39,20 @@ class Logger {
    * \param error_output: `FILE *` Pointer to an output file for error messages
    * (optional, default is `stderr`).
    */
-  Logger(int threshold, FILE *logging_output=std::stdout, FILE *error_output=std::stderr);
+  Logger(int threshold, FILE *logging_output=stdout, FILE *error_output=stderr);
 
-  log(std::string message, int level);
+  /*! \brief Print a message to the error output.
+   *
+   * \param message: `string` The message to be printed.
+   */
+  void err(std::string message);
+
+  /*! \brief Print a message, depending on its logging level.
+   *
+   * \param message: `string` The message to be printed.
+   * \param level: `int` The priority level (default is `LOG_INFO = 1`).
+   */
+  void log(std::string message, int level=LOG_INFO);
 };
 
 #endif
diff --git a/src/libnptm/Makefile b/src/libnptm/Makefile
index 43b886ff..de9085d0 100644
--- a/src/libnptm/Makefile
+++ b/src/libnptm/Makefile
@@ -19,11 +19,11 @@ endif
 include ../make.inc
 
 
-CXX_NPTM_OBJS=$(OBJDIR)/Commons.o $(OBJDIR)/Configuration.o $(OBJDIR)/file_io.o $(OBJDIR)/Parsers.o $(OBJDIR)/sph_subs.o $(OBJDIR)/clu_subs.o $(OBJDIR)/tfrfme.o $(OBJDIR)/tra_subs.o $(OBJDIR)/TransitionMatrix.o $(OBJDIR)/lapack_calls.o $(OBJDIR)/algebraic.o $(OBJDIR)/types.o
+CXX_NPTM_OBJS=$(OBJDIR)/Commons.o $(OBJDIR)/Configuration.o $(OBJDIR)/file_io.o $(OBJDIR)/Parsers.o $(OBJDIR)/sph_subs.o $(OBJDIR)/clu_subs.o $(OBJDIR)/tfrfme.o $(OBJDIR)/tra_subs.o $(OBJDIR)/TransitionMatrix.o $(OBJDIR)/lapack_calls.o $(OBJDIR)/algebraic.o $(OBJDIR)/types.o $(OBJDIR)/logging.o
 
-CXX_NPTM_DYNOBJS=$(DYNOBJDIR)/Commons.o $(DYNOBJDIR)/Configuration.o $(DYNOBJDIR)/file_io.o $(DYNOBJDIR)/Parsers.o $(DYNOBJDIR)/sph_subs.o $(DYNOBJDIR)/clu_subs.o $(DYNOBJDIR)/tfrfme.o $(DYNOBJDIR)/tra_subs.o $(DYNOBJDIR)/TransitionMatrix.o $(DYNOBJDIR)/lapack_calls.o $(DYNOBJDIR)/algebraic.o $(DYNOBJDIR)/types.o
+CXX_NPTM_DYNOBJS=$(DYNOBJDIR)/Commons.o $(DYNOBJDIR)/Configuration.o $(DYNOBJDIR)/file_io.o $(DYNOBJDIR)/Parsers.o $(DYNOBJDIR)/sph_subs.o $(DYNOBJDIR)/clu_subs.o $(DYNOBJDIR)/tfrfme.o $(DYNOBJDIR)/tra_subs.o $(DYNOBJDIR)/TransitionMatrix.o $(DYNOBJDIR)/lapack_calls.o $(DYNOBJDIR)/algebraic.o $(DYNOBJDIR)/types.o $(DYNOBJDIR)/logging.o
 
-CXX_NPTM_DEBUG=$(OBJDIR)/Commons.g* $(OBJDIR)/Configuration.g* $(OBJDIR)/file_io.g* $(OBJDIR)/Parsers.g* $(OBJDIR)/sph_subs.g* $(OBJDIR)/clu_subs.g* $(OBJDIR)/tfrfme.g* $(OBJDIR)/tra_subs.g* $(OBJDIR)/TransitionMatrix.g* $(OBJDIR)/lapack_calls.g* $(OBJDIR)/algebraic.g* $(OBJDIR)/types.g* $(DYNOBJDIR)/Commons.g* $(DYNOBJDIR)/Configuration.g* $(DYNOBJDIR)/file_io.g* $(DYNOBJDIR)/Parsers.g* $(DYNOBJDIR)/sph_subs.g* $(DYNOBJDIR)/clu_subs.g* $(DYNOBJDIR)/tfrfme.g* $(DYNOBJDIR)/tra_subs.g* $(DYNOBJDIR)/TransitionMatrix.g* $(DYNOBJDIR)/lapack_calls.g* $(DYNOBJDIR)/algebraic.g* $(DYNOBJDIR)/types.g*
+CXX_NPTM_DEBUG=$(OBJDIR)/Commons.g* $(OBJDIR)/Configuration.g* $(OBJDIR)/file_io.g* $(OBJDIR)/Parsers.g* $(OBJDIR)/sph_subs.g* $(OBJDIR)/clu_subs.g* $(OBJDIR)/tfrfme.g* $(OBJDIR)/tra_subs.g* $(OBJDIR)/TransitionMatrix.g* $(OBJDIR)/lapack_calls.g* $(OBJDIR)/algebraic.g* $(OBJDIR)/types.g* $(OBJDIR)/logging.g* $(DYNOBJDIR)/Commons.g* $(DYNOBJDIR)/Configuration.g* $(DYNOBJDIR)/file_io.g* $(DYNOBJDIR)/Parsers.g* $(DYNOBJDIR)/sph_subs.g* $(DYNOBJDIR)/clu_subs.g* $(DYNOBJDIR)/tfrfme.g* $(DYNOBJDIR)/tra_subs.g* $(DYNOBJDIR)/TransitionMatrix.g* $(DYNOBJDIR)/lapack_calls.g* $(DYNOBJDIR)/algebraic.g* $(DYNOBJDIR)/types.g* $(DYNOBJDIR)/logging.g*
 
 all: $(BUILDDIR_NPTM)/libnptm.a $(BUILDDIR_NPTM)/libnptm.so
 
diff --git a/src/libnptm/logging.cpp b/src/libnptm/logging.cpp
index a1d0a648..e8676315 100644
--- a/src/libnptm/logging.cpp
+++ b/src/libnptm/logging.cpp
@@ -19,9 +19,13 @@ Logger::Logger(int threshold, FILE *logging_output, FILE *error_output) {
   err_output = error_output;
 }
 
-Logger::log(std::string message, int level) {
+void Logger::err(std::string message) {
+  fprintf(err_output, "%s\n", message.c_str());
+}
+
+void Logger::log(std::string message, int level) {
   if (level == LOG_ERRO) err(message);
   else {
-    if (level >= log_threshold) fprintf(log_output, message);
+    if (level >= log_threshold) fprintf(log_output, "%s\n", message.c_str());
   }
 }
-- 
GitLab