On Mon, Mar 10, 2014 at 6:14 PM, Felipe Magno de Almeida <felipe.m.alme...@gmail.com> wrote: > On Mon, Mar 10, 2014 at 5:47 PM, Felipe Magno de Almeida > <felipe.m.alme...@gmail.com> wrote: >> On Mon, Mar 10, 2014 at 5:02 PM, Felipe Magno de Almeida >> <felipe.m.alme...@gmail.com> wrote: >>> Hello Gustavo, >> >> [snip] >> >> Hello Gustavo, >> >>> What I *may* do is: (without impacting performance) >>> >>> EINA_CXX_DOM_LOG_CRIT(domain) << "hello world " << 0.3456; >>> >>> But I'm not 100% sure. >> >> Yeah, I think I can do it using a trick with some for statements: >> >> #define EINA_CXX_DOM_LOG(DOMAIN, LEVEL) \ >> for( bool stop = false ; !stop ; stop = true ) \ >> for(std::stringstream stream; !stop && >> ::eina_log_domain_level_check((DOMAIN), LEVEL); \ >> ::efl::eina::_log(std::move(stream), (DOMAIN), LEVEL \ >> , __FILE__, __FUNCTION__, __LINE__), stop = >> true) \ >> stream >> >> This works: >> >> EINA_CXX_DOM_LOG_CRIT(domain) << "foo 0x" << std::hex << 10; >> >> [snip] >> >> Is this better? > > https://phab.enlightenment.org/D623
no, I'm complaining about a different issue. See my other email. I'm complaining about the syntax and usage. You can also think about a different solution where instead of locking and an internal "this.message" you keep a per-thread local storage, each thread appends to its own string/stringstream. Your idea to have a stack-allocated stream may work to avoid the issue as well, not sure if it will trigger a shadow warning if there is a "stream" variable set before or how that behaves with memory allocations. In any way there are multiple ways to achieve that, be your for() trick, Thread-Local-Storage or whatever. That's not my issue. Also, I do think we do NOT need one macro per level, that's an issue for C, but not for C++. Eventually we can even remove the CXX from the name as it doesn't conflict with C and use either EINA_CXX_LOG(stream) or EINA_LOG(stream). A small and simple way to log is essential to allow someone to use logs. The global log level just expose its level_as_stream as globals or efl::eina:log namespace, such as err, dbg, crit, inf, wrn... BTW, you don't need to cope with log domains created by C other than the global log level (that is a special case). If you want to use a log level in C++ you will be creating that in C++, there should be no reason to use one that was created by C and use that in C++. If one that that ever comes to happen, the developer can fallback to use the C macros. I'm telling you that because once you instantiate a new log domain you already instantiate the level_as_streams, or make it lazy-allocate based on usage. -- Gustavo Sverzut Barbieri -------------------------------------- Mobile: +55 (19) 99225-2202 Contact: http://www.gustavobarbieri.com.br/contact ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel