LoggerUtils not thread safe?

Edward BishopEdward Bishop Member EdwardOrganization: SonyProject: Automated Test ✭✭
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

  • matthewmatthew NL, CanadaMember Matthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications Engine ✭✭✭
    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";
       }
       ...
    }
    
  • Edward BishopEdward Bishop Member EdwardOrganization: SonyProject: Automated Test ✭✭
    OK, that make sense. Thanks for your help.

    -Edward
Sign In or Register to comment.