You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Paul Butcher <pa...@paulbutcher.com> on 2005/06/03 14:14:55 UTC

Status of stream.h?

I am having problems with the code within <log4cxx/stream.h>. Using it in a 
single source file works fine, but when I try to use it more than once, I get 
the following when linking:

In function `operator<<(log4cxx::logstream&, char const*)':
log4cxx/stream.h:153: multiple definition of `operator<<(log4cxx::logstream&, 
char const*)'

Plus a lot of other similar errors.

I'm using g++ (GCC) 3.3.4 (pre 3.3.5 20040809).

I get the impression that this code is still evolving? Is it ready for "prime 
time" yet? 

A wider question: what is the preferred mechanism for generating log messages 
which are more than just fixed strings?

Thanks in advance!

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

Re: Status of stream.h?

Posted by Curt Arnold <ca...@apache.org>.
Okay, I can see it.  The problem is that the "ArbitraryType" template  
in the bottom of stream.h isn't expanded to std::string.  I attempted  
a quick std::basic_string operator<< template and ended up having  
conflicts in other code due to having multiple template expansions  
and the compiler could not choose between them.

If you can add your own operator<< for std::string to stream.h until  
we can find a general implementation.

The suggestion to do:

LOG4CXX_DEBUG(logger, "i = " << i);

is log4cxx-0.9.7 specific and is going away.


On Jun 7, 2005, at 3:14 AM, Paul Butcher wrote:


> On Tuesday 07 June 2005 01:40, Curt Arnold wrote:
>
>
>> Hard to troubleshoot without that error message.  Could you at least
>> tell me what compiler and platform that you are encountering the
>> problem on?
>>
>>
>
> Sorry, Curt - the same as in my earlier message: g++ (GCC) 3.3.4  
> (pre 3.3.5
> 20040809) running on SUSE Linux 9.2. Here's a small test program which
> reproduces the problem:
>
> ------------------------------------------------------
> #include <log4cxx/stream.h>
> #include <log4cxx/basicconfigurator.h>
>
> #include <string>
>
> int main()
> {
>   log4cxx::BasicConfigurator::configure();
>   log4cxx::LoggerPtr logger = log4cxx::Logger::getRootLogger();
>
>   log4cxx::logstream logstream(logger, log4cxx::Level::DEBUG);
>   logstream << "test" << LOG4CXX_ENDMSG;
>
>   std::string foo = "foo";
>   logstream << foo;
>
>   return 0;
> }
> ------------------------------------------------------
>
> And here is the full error message:
>
> ------------------------------------------------------
> log4cxx/stream.h: In function `log4cxx::logstream&
>    operator<<(log4cxx::logstream&, const ArbitraryType&) [with  
> ArbitraryType =
>    std::string]':
> logtest.cpp:15:   instantiated from here
> log4cxx/stream.h:212: error: no match for 'operator<<' in '
>    (+lhs)->log4cxx::logstream::getStream() << rhs'
> /usr/include/g++/bits/ostream.tcc:63: error: candidates are:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(std::basic_ostream<_CharT,
>    _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT  
> = wchar_t,
>    _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:74: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(std::basic_ios<_CharT,
>    _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT =  
> wchar_t,
>    _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:86: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with  
> _CharT =
>    wchar_t, _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:122: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(long int) [with _CharT = wchar_t, _Traits =
>    std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:156: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(long unsigned int) [with _CharT = wchar_t,  
> _Traits =
>    std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:98: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(bool) [with _CharT = wchar_t, _Traits =
>    std::char_traits<wchar_t>]
> /usr/include/g++/ostream:178: error:
> std::basic_ostream<_CharT,
>    _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short  
> int) [with
>    _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/ostream:189: error:
> std::basic_ostream<_CharT,
>    _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short  
> unsigned
>    int) [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/ostream:193: error:
> std::basic_ostream<_CharT,
>    _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int)  
> [with _CharT
>    = wchar_t, _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/ostream:204: error:
> std::basic_ostream<_CharT,
>    _Traits>& std::basic_ostream<_CharT, _Traits>::operator<< 
> (unsigned int)
>    [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:181: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(long long int) [with _CharT = wchar_t,  
> _Traits =
>    std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:216: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(long long unsigned int) [with _CharT =  
> wchar_t,
> _Traits
>    = std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:241: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(double) [with _CharT = wchar_t, _Traits =
>    std::char_traits<wchar_t>]
> /usr/include/g++/ostream:219: error:
> std::basic_ostream<_CharT,
>    _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float)  
> [with
>    _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:265: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(long double) [with _CharT = wchar_t, _Traits =
>    std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:289: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(const void*) [with _CharT = wchar_t, _Traits =
>    std::char_traits<wchar_t>]
> /usr/include/g++/bits/ostream.tcc:313: error:
>    std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
>    _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*)  
> [with _CharT =
>    wchar_t, _Traits = std::char_traits<wchar_t>]
> log4cxx/stream.h:153: error:                 log4cxx::logstream&
>    operator<<(log4cxx::logstream&, const char*)
> log4cxx/stream.h:173: error:                 log4cxx::logstream&
>    operator<<(log4cxx::logstream&, const log4cxx::spi::LocationInfo&)
> log4cxx/stream.h:181: error:                 log4cxx::logstream&
>    operator<<(log4cxx::logstream&, const log4cxx::spi::LocationFlush&)
> log4cxx/stream.h:188: error:                 log4cxx::logstream&
>    operator<<(log4cxx::logstream&, const log4cxx::LevelPtr&)
> log4cxx/stream.h:196: error:                 log4cxx::logstream&
>    operator<<(log4cxx::logstream&, std::ios_base&(*)(std::ios_base&))
> log4cxx/stream.h:210: error:                 log4cxx::logstream&
>    operator<<(log4cxx::logstream&, const ArbitraryType&) [with  
> ArbitraryType =
>    std::string]
> /usr/include/g++/bits/ostream.tcc:572: error:
>    std::basic_ostream<_CharT, _Traits>&
>    std::operator<<(std::basic_ostream<_CharT, _Traits>&, const  
> char*) [with
>    _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
> /usr/include/g++/ostream:436: error:
> std::basic_ostream<_CharT,
>    _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&,  
> char) [with
>    _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
> ------------------------------------------------------
>
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?
>
>



Re: Status of stream.h?

Posted by Paul Butcher <pa...@paulbutcher.com>.
On Tuesday 07 June 2005 01:40, Curt Arnold wrote:
> Hard to troubleshoot without that error message.  Could you at least
> tell me what compiler and platform that you are encountering the
> problem on?

Sorry, Curt - the same as in my earlier message: g++ (GCC) 3.3.4 (pre 3.3.5 
20040809) running on SUSE Linux 9.2. Here's a small test program which 
reproduces the problem:

------------------------------------------------------
#include <log4cxx/stream.h>
#include <log4cxx/basicconfigurator.h>

#include <string>

int main()
{
  log4cxx::BasicConfigurator::configure();
  log4cxx::LoggerPtr logger = log4cxx::Logger::getRootLogger();

  log4cxx::logstream logstream(logger, log4cxx::Level::DEBUG);
  logstream << "test" << LOG4CXX_ENDMSG;

  std::string foo = "foo";
  logstream << foo;

  return 0;
}
------------------------------------------------------

And here is the full error message:

------------------------------------------------------
log4cxx/stream.h: In function `log4cxx::logstream&
   operator<<(log4cxx::logstream&, const ArbitraryType&) [with ArbitraryType =
   std::string]':
logtest.cpp:15:   instantiated from here
log4cxx/stream.h:212: error: no match for 'operator<<' in '
   (+lhs)->log4cxx::logstream::getStream() << rhs'
/usr/include/g++/bits/ostream.tcc:63: error: candidates are:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_ostream<_CharT,
   _Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = wchar_t,
   _Traits = std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:74: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_ios<_CharT,
   _Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = wchar_t,
   _Traits = std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:86: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT =
   wchar_t, _Traits = std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:122: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long int) [with _CharT = wchar_t, _Traits =
   std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:156: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long unsigned int) [with _CharT = wchar_t, _Traits =
   std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:98: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(bool) [with _CharT = wchar_t, _Traits =
   std::char_traits<wchar_t>]
/usr/include/g++/ostream:178: error:                 
std::basic_ostream<_CharT,
   _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with
   _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
/usr/include/g++/ostream:189: error:                 
std::basic_ostream<_CharT,
   _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned
   int) [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
/usr/include/g++/ostream:193: error:                 
std::basic_ostream<_CharT,
   _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT
   = wchar_t, _Traits = std::char_traits<wchar_t>]
/usr/include/g++/ostream:204: error:                 
std::basic_ostream<_CharT,
   _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int)
   [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:181: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long long int) [with _CharT = wchar_t, _Traits =
   std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:216: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long long unsigned int) [with _CharT = wchar_t, 
_Traits
   = std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:241: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(double) [with _CharT = wchar_t, _Traits =
   std::char_traits<wchar_t>]
/usr/include/g++/ostream:219: error:                 
std::basic_ostream<_CharT,
   _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with
   _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:265: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(long double) [with _CharT = wchar_t, _Traits =
   std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:289: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(const void*) [with _CharT = wchar_t, _Traits =
   std::char_traits<wchar_t>]
/usr/include/g++/bits/ostream.tcc:313: error:
   std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
   _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT =
   wchar_t, _Traits = std::char_traits<wchar_t>]
log4cxx/stream.h:153: error:                 log4cxx::logstream&
   operator<<(log4cxx::logstream&, const char*)
log4cxx/stream.h:173: error:                 log4cxx::logstream&
   operator<<(log4cxx::logstream&, const log4cxx::spi::LocationInfo&)
log4cxx/stream.h:181: error:                 log4cxx::logstream&
   operator<<(log4cxx::logstream&, const log4cxx::spi::LocationFlush&)
log4cxx/stream.h:188: error:                 log4cxx::logstream&
   operator<<(log4cxx::logstream&, const log4cxx::LevelPtr&)
log4cxx/stream.h:196: error:                 log4cxx::logstream&
   operator<<(log4cxx::logstream&, std::ios_base&(*)(std::ios_base&))
log4cxx/stream.h:210: error:                 log4cxx::logstream&
   operator<<(log4cxx::logstream&, const ArbitraryType&) [with ArbitraryType =
   std::string]
/usr/include/g++/bits/ostream.tcc:572: error:
   std::basic_ostream<_CharT, _Traits>&
   std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with
   _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
/usr/include/g++/ostream:436: error:                 
std::basic_ostream<_CharT,
   _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with
   _CharT = wchar_t, _Traits = std::char_traits<wchar_t>]
------------------------------------------------------

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

Re: Status of stream.h?

Posted by Curt Arnold <ca...@apache.org>.
On Jun 6, 2005, at 4:00 PM, Paul Butcher wrote:



> Thanks for the various responses on this topic.
>
> On Monday 06 June 2005 19:57, Curt Arnold wrote:
>
>
>
>> It has been stalled for quite some time, however Christopher Smith
>> has expressed interest in restarting it.  The semantics shouldn't
>> change much but ...
>>
>>
>>
>
> I haven't looked into it in great detail, so can't suggest a  
> solution, but I
> suspect that it will need a change to the semantics to be useful.  
> At the
> moment, very simple constructs like:
>
>   log4cxx::logstream ls(logger, Level::DEBUG);
>   std::string s = "Test";
>   ls << s;
>
> fail (with a very long template-related error message which I won't  
> reproduce
> here).
>
>
>

Hard to troubleshoot without that error message.  Could you at least  
tell me what compiler and platform that you are encountering the  
problem on?





> It seems to work with simple types (char*, int, etc) but not with  
> anything
> more complex :-(
>
>



>
>
>




> Thanks - but am I right in thinking that this isn't available in  
> log4cxx just
> yet?
>
>
>


It is there for feedback and development.  If you can give a little  
more details maybe we can get it working for you in very short order.




> What I've been doing for the time being is this kind of thing:
>
>   std::ostringstream message;
>   message << ... ;
>   LOG4CXX_DEBUG(logger, message.str());
>
>

The std::ostringstream constructor is extremely expensive on some STL  
implementations.  The current logstream implementation is better than  
that, but doesn't approach a NOP when logging is disabled..




>
> or, if efficiency matters:
>
>   if(logger->isDebugEnabled())
>   {
>     std::ostringstream message;
>     message << ... ;
>     LOG4CXX_DEBUG(logger, message.str());
>   }
>
> Is this the best option with the package as it currently stands? Or  
> is there a
> better alternative?
>
>

Fixing the logstream at least enough for your immediate needs would  
be a better alternative, getting it performant would be even better.   
If those aren't achievable in your timeframe, then it would be better  
for you to define a few macros or functions than to reproduce that  
boilerplate code.



Re: Status of stream.h?

Posted by Kyle Cavin <be...@gmail.com>.
I'm not sure if this applies directly, but I've been using the macros 
directly with streams. for example:

    LOG4CXX(logger,"there are " << 10 << std::string("peach cobblers") 
<< my::class("kansas"));

This compiles and works fine for me with gcc-3.3.5 and log4cxx-0.9.7. 
Hope this helps.

Re: Status of stream.h?

Posted by Paul Butcher <pa...@paulbutcher.com>.
Thanks for the various responses on this topic.

On Monday 06 June 2005 19:57, Curt Arnold wrote:
> It has been stalled for quite some time, however Christopher Smith
> has expressed interest in restarting it.  The semantics shouldn't
> change much but ...

I haven't looked into it in great detail, so can't suggest a solution, but I 
suspect that it will need a change to the semantics to be useful. At the 
moment, very simple constructs like:

  log4cxx::logstream ls(logger, Level::DEBUG);
  std::string s = "Test";
  ls << s;

fail (with a very long template-related error message which I won't reproduce 
here).

It seems to work with simple types (char*, int, etc) but not with anything 
more complex :-(

> log4j's CVS HEAD has a parameterized log methods that could mimicked
> in log4cxx, but I haven't mocked anything out.  The new log4j methods
> are something like:
>
> logger.info("Hello, {}.", "World");
>
> It isn't the most general approach, but it does cover a huge amount
> of common use cases.

Thanks - but am I right in thinking that this isn't available in log4cxx just 
yet?

What I've been doing for the time being is this kind of thing:

  std::ostringstream message;
  message << ... ;
  LOG4CXX_DEBUG(logger, message.str());

or, if efficiency matters:

  if(logger->isDebugEnabled())
  {
    std::ostringstream message;
    message << ... ;
    LOG4CXX_DEBUG(logger, message.str());
  }

Is this the best option with the package as it currently stands? Or is there a 
better alternative?

Thanks!

paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

Re: Status of stream.h?

Posted by Curt Arnold <ca...@apache.org>.
On Jun 3, 2005, at 7:14 AM, Paul Butcher wrote:

> I am having problems with the code within <log4cxx/stream.h>. Using  
> it in a
> single source file works fine, but when I try to use it more than  
> once, I get
> the following when linking:
>
> In function `operator<<(log4cxx::logstream&, char const*)':
> log4cxx/stream.h:153: multiple definition of `operator<< 
> (log4cxx::logstream&,
> char const*)'
>
> Plus a lot of other similar errors.
>
> I'm using g++ (GCC) 3.3.4 (pre 3.3.5 20040809).
>
> I get the impression that this code is still evolving? Is it ready  
> for "prime
> time" yet?
>

It has been stalled for quite some time, however Christopher Smith  
has expressed interest in restarting it.  The semantics shouldn't  
change much but the current approach has a surprisingly high cost to  
instantiate a logstream object.  It is not trivial to preserve the  
STL stream semantics while deferring the startup cost until the first  
logging request that satisfies the criteria.

> A wider question: what is the preferred mechanism for generating  
> log messages
> which are more than just fixed strings?

log4j's CVS HEAD has a parameterized log methods that could mimicked  
in log4cxx, but I haven't mocked anything out.  The new log4j methods  
are something like:

logger.info("Hello, {}.", "World");


It isn't the most general approach, but it does cover a huge amount  
of common use cases.



>
> Thanks in advance!
>
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?
>


Re: Status of stream.h?

Posted by Andreas Fester <An...@gmx.de>.
Hi Paul,

Paul Butcher wrote:
> I am having problems with the code within <log4cxx/stream.h>. Using it in a 
> single source file works fine, but when I try to use it more than once, I get 
> the following when linking:
> 
> In function `operator<<(log4cxx::logstream&, char const*)':
> log4cxx/stream.h:153: multiple definition of `operator<<(log4cxx::logstream&, 
> char const*)'

I can reproduce this. I created some cpp files with content similar to

#include <log4cxx/level.h>
#include <log4cxx/logger.h>
#include <log4cxx/stream.h>

#include "src1.h"

using namespace log4cxx;

static LoggerPtr logger = Logger::getLogger(L"Src1");

void src1() {
   logstream info(logger, Level::INFO);
   info << "In src1.cpp" << 4.5 << " / " << 4;

   info.flush();
}

and then also get a lot of those messages

src1.o(.text+0x0): In function `operator<<(log4cxx::logstream&, char 
const*)':
: multiple definition of `operator<<(log4cxx::logstream&, char const*)'
main.o(.text+0x0): first defined here

Maybe I can have a closer look to it tomorrow...

> I get the impression that this code is still evolving? Is it ready for "prime 
> time" yet? 
> 
> A wider question: what is the preferred mechanism for generating log messages 
> which are more than just fixed strings?

I think that using a logstream is a proper approach, at least
I like this more than concatenating lots of strings (and probably
do lot of conversions myself) and the using LOG4CXX_ macros. So
something like

	logstream info(logger, Level::INFO);
	info << "In src1.cpp" << 4.5 << " / " << 4;

seems a proper solution for me.

Regards,

	Andreas

-- 
Andreas Fester
mailto:Andreas.Fester@gmx.de
WWW: http://littletux.homelinux.org
ICQ: 326674288

Re: Status of stream.h?

Posted by Andreas Fester <An...@gmx.de>.
Hi,

there were some global operator definitions in the header file which
caused the multiple definition errors. Apply the attached patch
to fix the problem.

Curt: I would like to suggest to rename "stream.h" to "logstream.h"
because this is also the name of the class and it gives a better
idea of what the header file is for.

Best Regards,

	Andreas

Paul Butcher wrote:
> I am having problems with the code within <log4cxx/stream.h>. Using it in a 
> single source file works fine, but when I try to use it more than once, I get 
> the following when linking:
> 
> In function `operator<<(log4cxx::logstream&, char const*)':
> log4cxx/stream.h:153: multiple definition of `operator<<(log4cxx::logstream&, 
> char const*)'
[...]

-- 
Andreas Fester
mailto:Andreas.Fester@gmx.de
WWW: http://littletux.homelinux.org
ICQ: 326674288