Archived

This forum has been archived. Please start a new discussion on GitHub.

LoggerUtils not thread safe?

I see that the code in LoggerI.cpp is protected with a global mutex, but it seems that the utilities like Ice::Trace are not.

Even though they send to the logger, their stream is not protected:
[INDENT]Trace&
Ice::operator<<(Trace& out, ios_base& (*val)(ios_base&))
{
    out.__str() << val;
    return out;
}[/INDENT]

Am I right? Should we not share Ice::Trace (Warn, Error) objects between threads?

Thanks,
Edward

Comments

  • matthew
    matthew NL, Canada
    I think that would be a rather strange usage. The intent is to instantiate them on the stack at the point that you want to trace. For example:
    void
    FooI::dosomething(const Ice::Current&)
    {
       if(_traceLevel > 0)
       {
          Ice::Trace trace("FooI", _logger);
          trace << "dosomething";
       }
       ...
    }
    
  • OK, that make sense. Thanks for your help.

    -Edward