Skip to content

Commit

Permalink
XrdCl: Display pid in the log message if set
Browse files Browse the repository at this point in the history
  • Loading branch information
ljanyst committed Feb 13, 2015
1 parent a5b6309 commit ab1a8f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/XrdCl/XrdClLog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ namespace XrdCl
while( (line = tok.GetLine()) )
{
out << "[" << now << "][" << LogLevelToString( level ) << "]";
out << "[" << TopicToString( topic ) << "] " << line << std::endl;
out << "[" << TopicToString( topic ) << "]";
if(pPid) out << "[" << std::setw(5) << pPid << "]";
out << " " << line << std::endl;
}

pOutput->Write( out.str() );
Expand Down
11 changes: 10 additions & 1 deletion src/XrdCl/XrdClLog.hh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace XrdCl
//------------------------------------------------------------------------
//! Constructor
//------------------------------------------------------------------------
Log(): pLevel( NoMsg ), pTopicMaxLength( 18 )
Log(): pLevel( NoMsg ), pTopicMaxLength( 18 ), pPid(0)
{
pOutput = new LogOutCerr();
int maxMask = (int)DumpMsg+1;
Expand Down Expand Up @@ -298,6 +298,14 @@ namespace XrdCl
#endif
}

//------------------------------------------------------------------------
//! Set pid
//------------------------------------------------------------------------
void SetPid(pid_t pid)
{
pPid = pid;
}

private:
typedef std::map<uint64_t, std::string> TopicMap;
std::string LogLevelToString( LogLevel level );
Expand All @@ -313,6 +321,7 @@ namespace XrdCl
LogOut *pOutput;
TopicMap pTopicMap;
uint32_t pTopicMaxLength;
pid_t pPid;
};
}

Expand Down

0 comments on commit ab1a8f3

Please sign in to comment.