Git Product home page Git Product logo

Comments (5)

eddelbuettel avatar eddelbuettel commented on June 15, 2024 2

Holy smokes. That did it. If you look at src/exampleFour.cpp I was already a bit more careful:

//#include "spdlog/spdlog.h"
//#include "spdlog/sinks/stdout_color_sinks.h"
#include <spdlog/details/synchronous_factory.h>
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/null_mutex.h"
//#include "spdlog/sinks/basic_file_sink.h"
#include <mutex>
#include <Rcpp.h>

but that now does it:

edd@rob:~/git/rcppspdlog(feature/with_src)$ git diff src/exampleFour.cpp
diff --git a/src/exampleFour.cpp b/src/exampleFour.cpp
index 99fcff4..f770a0b 100644
--- a/src/exampleFour.cpp
+++ b/src/exampleFour.cpp
@@ -1,4 +1,5 @@
 
+#define SPDLOG_DISABLE_DEFAULT_LOGGER 1
 //#include "spdlog/spdlog.h"
 //#include "spdlog/sinks/stdout_color_sinks.h"
 #include <spdlog/details/synchronous_factory.h>
edd@rob:~/git/rcppspdlog(feature/with_src)$ 

Clean as a whistle:
image

from rcppspdlog.

gabime avatar gabime commented on June 15, 2024

Could this line be the cause of this warning?

from rcppspdlog.

eddelbuettel avatar eddelbuettel commented on June 15, 2024

You are very very good. I am not sure how I missed that in my attempts. Now, the stdout and stderr checks are independent but we are now down to

* checking compiled code ... NOTE
File ‘RcppSpdlog/libs/RcppSpdlog.so’:
  Found ‘stdout’, possibly from ‘stdout’ (C)
    Object: ‘exampleFour.o’

Compiled code should not call entry points which might terminate R nor write to stdout/stderr instead
of to the console, nor use Fortran I/O nor system RNGs.

See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual.
* checking examples ... OK

with this simple diff

edd@rob:~/git/rcppspdlog(feature/with_src)$ git diff inst/include/spdlog/logger-inl.h
diff --git a/inst/include/spdlog/logger-inl.h b/inst/include/spdlog/logger-inl.h
index 69d6a1d..da8147a 100644
--- a/inst/include/spdlog/logger-inl.h
+++ b/inst/include/spdlog/logger-inl.h
@@ -12,7 +12,7 @@
 #include <spdlog/pattern_formatter.h>
 
 #include <cstdio>
-
+#include <Rcpp.h>
 namespace spdlog {
 
 // public methods
@@ -247,7 +247,8 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg)
         auto tm_time = details::os::localtime(system_clock::to_time_t(now));
         char date_buf[64];
         std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time);
-        fprintf(stderr, "[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str());
+        //fprintf(stderr, "[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str());
+        REprintf("[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str());
     }
 }
 } // namespace spdlog
edd@rob:~/git/rcppspdlog(feature/with_src)$ 

(where REprintf() is R's fprintf(stderr, ...), we have Rprintf() for the normal case).

Now for the remaining stdout or couple of them. It is really really helpful that your library is so good about 'include what you use' (whereas in Rcpp for example we go with the kitchen sink approach 🤦‍♂️ ... which makes it easier on the user though).

from rcppspdlog.

gabime avatar gabime commented on June 15, 2024

Please try to define SPDLOG_DISABLE_DEFAULT_LOGGER before including spdlog.h

This will prevent spdlog the include for ansicolor_sink.h which might cause the last warning

from rcppspdlog.

eddelbuettel avatar eddelbuettel commented on June 15, 2024

All good now and merged. Thanks again @gabime !

from rcppspdlog.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.