Skip to content

Commit

Permalink
[XrdCl] Make it possible to tweak log settings in the default env
Browse files Browse the repository at this point in the history
  • Loading branch information
ljanyst committed Jun 6, 2013
1 parent 20acc93 commit 5e28d1d
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/XrdCl/XrdClDefaultEnv.cc
Expand Up @@ -221,6 +221,56 @@ namespace XrdCl
return sLog;
}

//----------------------------------------------------------------------------
// Set log level
//----------------------------------------------------------------------------
void DefaultEnv::SetLogLevel( const std::string &level )
{
Log *log = GetLog();
log->SetLevel( level );
}

//----------------------------------------------------------------------------
// Set log file
//----------------------------------------------------------------------------
bool DefaultEnv::SetLogFile( const std::string &filepath )
{
Log *log = GetLog();
LogOutFile *out = new LogOutFile();

if( out->Open( filepath ) )
{
log->SetOutput( out );
return true;
}

delete out;
return false;
}

//----------------------------------------------------------------------------
//! Set log mask.
//------------------------------------------------------------------------
void DefaultEnv::SetLogMask( const std::string &level,
const std::string &mask )
{
Log *log = GetLog();
MaskTranslator translator;
uint64_t topicMask = translator.translateMask( mask );

if( level == "All" )
{
log->SetMask( Log::ErrorMsg, topicMask );
log->SetMask( Log::WarningMsg, topicMask );
log->SetMask( Log::InfoMsg, topicMask );
log->SetMask( Log::DebugMsg, topicMask );
log->SetMask( Log::DumpMsg, topicMask );
return;
}

log->SetMask( level, topicMask );
}

//----------------------------------------------------------------------------
// Get fork handler
//----------------------------------------------------------------------------
Expand Down
39 changes: 39 additions & 0 deletions src/XrdCl/XrdClDefaultEnv.hh
Expand Up @@ -63,6 +63,45 @@ namespace XrdCl
//------------------------------------------------------------------------
static Log *GetLog();

//------------------------------------------------------------------------
//! Set log level
//!
//! @param level Dump, Debug, Info, Warning or Error
//------------------------------------------------------------------------
static void SetLogLevel( const std::string &level );

//------------------------------------------------------------------------
//! Set log file
//!
//! @param filepath path to the log file
//------------------------------------------------------------------------
static bool SetLogFile( const std::string &filepath );

//------------------------------------------------------------------------
//! Set log mask.
//! Determines which diagnostics topics should be printed. It's a
//! "|" separated list of topics. The first element may be "All" in which
//! case all the topics are enabled and the subsequent elements may turn
//! them off, or "None" in which case all the topics are disabled and
//! the subsequent flags may turn them on. If the topic name is prefixed
//! with "^", then it means that the topic should be disabled. If the
//! topic name is not prefixed, then it means that the topic should be
//! enabled.
//!
//! The default for each level is "All", except for the "Dump" level,
//! where the default is "All|^PollerMsg". This means that, at the
//! "Dump" level, all the topics but "PollerMsg" are enabled.
//!
//! Available topics: AppMsg, UtilityMsg, FileMsg, PollerMsg,
//! PostMasterMsg, XRootDTransportMsg, TaskMgrMsg, XRootDMsg,
//! FileSystemMsg, AsyncSockMsg
//!
//! @param level log level or "All" for all levels
//! @param mask log mask
//------------------------------------------------------------------------
static void SetLogMask( const std::string &level,
const std::string &mask );

//------------------------------------------------------------------------
//! Get the fork handler
//------------------------------------------------------------------------
Expand Down

0 comments on commit 5e28d1d

Please sign in to comment.