libzypp 17.38.1
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 (const LogControlImpl &)=delete
 LogControlImpl (LogControlImpl &&)=delete
LogControlImploperator= (const LogControlImpl &)=delete
LogControlImploperator= (LogControlImpl &&)=delete
 ~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

using StreamPtr = shared_ptr<Loglinestream>
using StreamSet = std::map<LogLevel, StreamPtr>
using StreamTable = std::map<std::string, StreamSet>

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

(Note that these are not member symbols.)

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 563 of file LogControl.cc.

Member Typedef Documentation

◆ StreamPtr

◆ StreamSet

Definition at line 691 of file LogControl.cc.

◆ StreamTable

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

Definition at line 692 of file LogControl.cc.

Constructor & Destructor Documentation

◆ LogControlImpl() [1/3]

Singleton ctor.

No logging per default, unless enabled via $ZYPP_LOGFILE.

Definition at line 712 of file LogControl.cc.

◆ LogControlImpl() [2/3]

zypp::base::logger::LogControlImpl::LogControlImpl ( const LogControlImpl & )
delete

◆ LogControlImpl() [3/3]

◆ ~LogControlImpl()

Member Function Documentation

◆ isExcessive()

Definition at line 566 of file LogControl.cc.

◆ excessive()

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

Definition at line 568 of file LogControl.cc.

◆ hideThreadName() [1/2]

Hint for Formater whether to hide the thread name.

Definition at line 573 of file LogControl.cc.

◆ hideThreadName() [2/2]

Definition at line 580 of file LogControl.cc.

◆ instanceHideThreadName() [1/2]

Definition at line 584 of file LogControl.cc.

◆ instanceHideThreadName() [2/2]

Definition at line 590 of file LogControl.cc.

◆ instanceLogToPPID()

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

Definition at line 597 of file LogControl.cc.

◆ instanceSetLogToPPID()

Definition at line 604 of file LogControl.cc.

◆ setLineWriter()

NULL _lineWriter indicates no loggin.

Definition at line 612 of file LogControl.cc.

◆ getLineWriter()

◆ setLineFormater()

Assert _lineFormater is not NULL.

Definition at line 619 of file LogControl.cc.

◆ logfile()

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

Definition at line 627 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 648 of file LogControl.cc.

◆ putRawLine()

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

Definition at line 672 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 677 of file LogControl.cc.

◆ readEnvVars()

Definition at line 699 of file LogControl.cc.

◆ operator=() [1/2]

LogControlImpl & zypp::base::logger::LogControlImpl::operator= ( const LogControlImpl & )
delete

◆ operator=() [2/2]

LogControlImpl & zypp::base::logger::LogControlImpl::operator= ( LogControlImpl && )
delete

◆ instance()

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 747 of file LogControl.cc.

◆ operator<<()

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

Stream output.

Definition at line 758 of file LogControl.cc.

Member Data Documentation

◆ _logClient

◆ _no_stream

Definition at line 639 of file LogControl.cc.

◆ _excessive

Definition at line 640 of file LogControl.cc.

◆ _logToPPIDMode

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

Definition at line 641 of file LogControl.cc.

◆ _hideThreadName

Hint for Formater whether to hide the thread name.

Definition at line 642 of file LogControl.cc.

◆ _lineFormater

◆ _streamtable

one streambuffer per group and level

Definition at line 694 of file LogControl.cc.

◆ _sock


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