libzypp 17.31.23
zypp::base::logger::LogControlImpl Struct Reference

LogControl implementation (thread_local Singleton). More...

Public Member Functions

bool isExcessive () const
 
void excessive (bool onOff_r)
 
bool hideThreadName () const
 Hint for Formater whether to hide the thread name.
 
void hideThreadName (bool onOff_r)
 
void setLineWriter (const shared_ptr< LogControl::LineWriter > &writer_r)
 NULL _lineWriter indicates no loggin.
 
shared_ptr< LogControl::LineWritergetLineWriter () const
 
void setLineFormater (const shared_ptr< LogControl::LineFormater > &format_r)
 Assert _lineFormater is not NULL.
 
void logfile (const Pathname &logfile_r, mode_t mode_r=0640)
 
std::ostream & getStream (const std::string &group_r, LogLevel level_r, const char *file_r, const char *func_r, const int line_r)
 Provide the log stream to write (logger interface)
 
void putRawLine (std::string &&line)
 
void putStream (const std::string &group_r, LogLevel level_r, const char *file_r, const char *func_r, int line_r, const std::string &message_r)
 Format and write out a logline from Loglinebuf.
 
 ~LogControlImpl ()
 

Static Public Member Functions

static bool instanceHideThreadName ()
 
static void instanceHideThreadName (bool onOff_r)
 
static bool instanceLogToPPID ()
 Hint for formatter wether we forward all logs to a parents log.
 
static void instanceSetLogToPPID (bool onOff_r)
 
static LogControlImplinstance ()
 The LogControlImpl singleton.
 

Private Types

typedef shared_ptr< LoglinestreamStreamPtr
 
typedef std::map< LogLevel, StreamPtrStreamSet
 
typedef std::map< std::string, StreamSetStreamTable
 

Private Member Functions

void readEnvVars ()
 
 LogControlImpl ()
 Singleton ctor.
 

Private Attributes

LogClient _logClient
 
std::ostream _no_stream
 
bool _excessive
 
bool _logToPPIDMode = false
 Hint for formatter to use the PPID and always show the thread name.
 
TriBool _hideThreadName = indeterminate
 Hint for Formater whether to hide the thread name.
 
shared_ptr< LogControl::LineFormater_lineFormater
 
StreamTable _streamtable
 one streambuffer per group and level
 
zyppng::Socket::Ptr _sock
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const LogControlImpl &)
 Stream output.
 

Detailed Description

LogControl implementation (thread_local Singleton).

Note
There is a slight difference in using the _lineFormater and _lineWriter!
  • _lineFormater must not be NULL (create default LogControl::LineFormater)
  • _lineWriter is NULL if no logging is performed, this way we can pass _no_stream as logstream to the application, and avoid unnecessary formating of logliles, which would then be discarded when passed to some dummy LineWriter.

Definition at line 543 of file LogControl.cc.

Member Typedef Documentation

◆ StreamPtr

◆ StreamSet

Definition at line 672 of file LogControl.cc.

◆ StreamTable

typedef std::map<std::string,StreamSet> zypp::base::logger::LogControlImpl::StreamTable
private

Definition at line 673 of file LogControl.cc.

Constructor & Destructor Documentation

◆ LogControlImpl()

zypp::base::logger::LogControlImpl::LogControlImpl ( )
inlineprivate

Singleton ctor.

No logging per default, unless enabled via $ZYPP_LOGFILE.

Definition at line 693 of file LogControl.cc.

◆ ~LogControlImpl()

zypp::base::logger::LogControlImpl::~LogControlImpl ( )
inline

Definition at line 707 of file LogControl.cc.

Member Function Documentation

◆ isExcessive()

bool zypp::base::logger::LogControlImpl::isExcessive ( ) const
inline

Definition at line 546 of file LogControl.cc.

◆ excessive()

void zypp::base::logger::LogControlImpl::excessive ( bool  onOff_r)
inline

Definition at line 549 of file LogControl.cc.

◆ hideThreadName() [1/2]

bool zypp::base::logger::LogControlImpl::hideThreadName ( ) const
inline

Hint for Formater whether to hide the thread name.

Definition at line 554 of file LogControl.cc.

◆ hideThreadName() [2/2]

void zypp::base::logger::LogControlImpl::hideThreadName ( bool  onOff_r)
inline

Definition at line 561 of file LogControl.cc.

◆ instanceHideThreadName() [1/2]

static bool zypp::base::logger::LogControlImpl::instanceHideThreadName ( )
inlinestatic

Definition at line 565 of file LogControl.cc.

◆ instanceHideThreadName() [2/2]

static void zypp::base::logger::LogControlImpl::instanceHideThreadName ( bool  onOff_r)
inlinestatic

Definition at line 571 of file LogControl.cc.

◆ instanceLogToPPID()

static bool zypp::base::logger::LogControlImpl::instanceLogToPPID ( )
inlinestatic

Hint for formatter wether we forward all logs to a parents log.

Definition at line 578 of file LogControl.cc.

◆ instanceSetLogToPPID()

static void zypp::base::logger::LogControlImpl::instanceSetLogToPPID ( bool  onOff_r)
inlinestatic

Definition at line 585 of file LogControl.cc.

◆ setLineWriter()

void zypp::base::logger::LogControlImpl::setLineWriter ( const shared_ptr< LogControl::LineWriter > &  writer_r)
inline

NULL _lineWriter indicates no loggin.

Definition at line 593 of file LogControl.cc.

◆ getLineWriter()

shared_ptr< LogControl::LineWriter > zypp::base::logger::LogControlImpl::getLineWriter ( ) const
inline

Definition at line 596 of file LogControl.cc.

◆ setLineFormater()

void zypp::base::logger::LogControlImpl::setLineFormater ( const shared_ptr< LogControl::LineFormater > &  format_r)
inline

Assert _lineFormater is not NULL.

Definition at line 600 of file LogControl.cc.

◆ logfile()

void zypp::base::logger::LogControlImpl::logfile ( const Pathname logfile_r,
mode_t  mode_r = 0640 
)
inline

Definition at line 608 of file LogControl.cc.

◆ getStream()

std::ostream & zypp::base::logger::LogControlImpl::getStream ( const std::string &  group_r,
LogLevel  level_r,
const char *  file_r,
const char *  func_r,
const int  line_r 
)
inline

Provide the log stream to write (logger interface)

Definition at line 629 of file LogControl.cc.

◆ putRawLine()

void zypp::base::logger::LogControlImpl::putRawLine ( std::string &&  line)
inline

Definition at line 653 of file LogControl.cc.

◆ putStream()

void zypp::base::logger::LogControlImpl::putStream ( const std::string &  group_r,
LogLevel  level_r,
const char *  file_r,
const char *  func_r,
int  line_r,
const std::string &  message_r 
)
inline

Format and write out a logline from Loglinebuf.

Definition at line 658 of file LogControl.cc.

◆ readEnvVars()

void zypp::base::logger::LogControlImpl::readEnvVars ( )
inlineprivate

Definition at line 680 of file LogControl.cc.

◆ instance()

LogControlImpl * zypp::base::logger::LogControlImpl::instance ( )
inlinestatic

The LogControlImpl singleton.

Note
As most dtors log, it is inportant that the LogControlImpl instance is the last static variable destructed. At least destucted after all statics which log from their dtor.

Definition at line 723 of file LogControl.cc.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  str,
const LogControlImpl  
)
related

Stream output.

Definition at line 734 of file LogControl.cc.

Member Data Documentation

◆ _logClient

LogClient zypp::base::logger::LogControlImpl::_logClient
private

Definition at line 619 of file LogControl.cc.

◆ _no_stream

std::ostream zypp::base::logger::LogControlImpl::_no_stream
private

Definition at line 620 of file LogControl.cc.

◆ _excessive

bool zypp::base::logger::LogControlImpl::_excessive
private

Definition at line 621 of file LogControl.cc.

◆ _logToPPIDMode

bool zypp::base::logger::LogControlImpl::_logToPPIDMode = false
private

Hint for formatter to use the PPID and always show the thread name.

Definition at line 622 of file LogControl.cc.

◆ _hideThreadName

TriBool zypp::base::logger::LogControlImpl::_hideThreadName = indeterminate
mutableprivate

Hint for Formater whether to hide the thread name.

Definition at line 623 of file LogControl.cc.

◆ _lineFormater

shared_ptr<LogControl::LineFormater> zypp::base::logger::LogControlImpl::_lineFormater
private

Definition at line 625 of file LogControl.cc.

◆ _streamtable

StreamTable zypp::base::logger::LogControlImpl::_streamtable
private

one streambuffer per group and level

Definition at line 675 of file LogControl.cc.

◆ _sock

zyppng::Socket::Ptr zypp::base::logger::LogControlImpl::_sock
private

Definition at line 676 of file LogControl.cc.


The documentation for this struct was generated from the following file: