Hello Gustavo, On Mon, Mar 10, 2014 at 9:15 PM, Gustavo Sverzut Barbieri <barbi...@gmail.com> wrote: > On Mon, Mar 10, 2014 at 6:14 PM, Felipe Magno de Almeida
[snip] >>> 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. That patch does change the syntax, it was: EINA_CXX_DOM_LOG_CRIT(domain, "foo 0x" << std::hex << 10); It is now: EINA_CXX_DOM_LOG_CRIT(domain) << "foo 0x" << std::hex << 10; > You can also think about a different solution where instad of locking > and an internal "this.message" you keep a per-thread local storage, > each thread appends to its own string/stringstream. I really don't want to take that road unless it is really necessary, and I don't think it is necessary. > 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 That is possible, we can change the name though to something unlikely to clash. > or how that behaves with memory allocations. I don't understand what you mean here by memory allocations. Which issues could there be? And which 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. The for trick works OK and is the least expensive way. It also avoids calling the expensive_call unless it is going to be logged. > Also, I do think we do NOT need one macro per level, that's an issue > for C, but not for C++. OK. I hadn't thought of that. It is not unusual for C++ to use macros here to differentiate. But it is possible to have something nicer too. > 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. OK. So let me know if this is really what you want: EINA_LOG(err) << "error " << error_code; EINA_LOG(dbg) << "error " << error_code; EINA_LOG(crit) << "error " << error_code; efl::eina::log_domain my_domain("mylib", "yellow"); EINA_LOG(my_domain.err) << "error " << error_code; EINA_LOG(my_domain.dbg) << "error " << error_code; EINA_LOG(my_domain.crit) << "error " << error_code; Is the EINA_LOG(err) going to log on the default domain or the global domain? If it is this that you want I think this is doable. If not, let me know where is my misunderstanding. > 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. We don't really need any allocation at all except for the formatting. > -- > Gustavo Sverzut Barbieri > -------------------------------------- > Mobile: +55 (19) 99225-2202 > Contact: http://www.gustavobarbieri.com.br/contact Regards, -- Felipe Magno de Almeida ------------------------------------------------------------------------------ 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