libzypp: zypp::base::LogControl Class Reference

libzypp 17.38.6

zypp::base::LogControl Class Reference

Maintain logfile related options. More...

`#include <zypp-core/base/LogControl.h>`

## Classes
struct | LineFormater
| If you want to format loglines by yourself, derive from this, and overload `format`. More...
struct | JournalLineFormater
| Our default format but without date, host and PID info. More...
struct | TmpExcessive
| Turn on excessive logging for the lifetime of this object. More...
struct | TmpLineWriter
| Exchange LineWriter for the lifetime of this object. More...

## Public Types
using | LineWriter = log::LineWriter

## Public Member Functions
void | setLineFormater (const shared_ptr< LineFormater > &formater_r)
| Assign a LineFormater.
void | enableLogForwardingMode (bool enable=true)
void | logfile (const Pathname &logfile_r)
| Set path for the logfile.
void | logfile (const Pathname &logfile_r, mode_t mode_r)
void | logNothing ()
| Turn off logging.
void | logToStdErr ()
| Log to std::err.
void | emergencyShutdown ()
| will cause the log thread to exit and flush all sockets
void | logRawLine (std::string &&line)
| will push a line to the logthread without formatting it
shared_ptr< LineWriter > | getLineWriter () const
| Get the current LineWriter.
void | setLineWriter (const shared_ptr< LineWriter > &writer_r)
| Assign a LineWriter.

## Static Public Member Functions
static LogControl | instance ()
| Singleton access.
static void | notifyFork ()
| This will completely disable logging.

## Private Member Functions
| LogControl ()
| Default ctor: Singleton.

## Friends
std::ostream & | operator<< (std::ostream &str, const LogControl &obj)
| relates: LogControl Stream output

## Detailed Description

Maintain logfile related options.

Note
  A Singleton using a Singleton implementation class, that's why there is no _pimpl like in other classes.

Definition at line 96 of file LogControl.h.

## Member Typedef Documentation

## ◆ LineWriter

using zypp::base::LogControl::LineWriter = log::LineWriter

See also
  log::LineWriter

Definition at line 107 of file LogControl.h.

## Constructor & Destructor Documentation

## ◆ LogControl()

zypp::base::LogControl::LogControl | ( |  | ) |
| inlineprivate

Default ctor: Singleton.

Definition at line 228 of file LogControl.h.

## Member Function Documentation

## ◆ instance()

LogControl zypp::base::LogControl::instance | ( |  | ) |
| inlinestatic

Singleton access.

Definition at line 102 of file LogControl.h.

## ◆ setLineFormater()

void zypp::base::LogControl::setLineFormater | ( | const shared_ptr< LineFormater > & | formater_r | ) |

Assign a LineFormater.

If you want to format loglines by yourself. NULL installs the default formater.

Definition at line 924 of file LogControl.cc.

## ◆ enableLogForwardingMode()

void zypp::base::LogControl::enableLogForwardingMode | ( | bool | enable = true | ) |

Sets a special log mode that uses the ppid in the log output and always shows the thread name (if the default formatter is used). This is only used by internal zypp tools that directly want to log into the parents logfile.

Definition at line 932 of file LogControl.cc.

## ◆ logfile() [1/2]

void zypp::base::LogControl::logfile | ( | const Pathname & | logfile_r | ) |

Set path for the logfile.

Permission for logfiles is set to 0640 unless an explicit mode_t value is given. An empty pathname turns off logging. "-" logs to std::err.

Exceptions

  if | logfile_r is not usable.

Definition at line 889 of file LogControl.cc.

## ◆ logfile() [2/2]

void zypp::base::LogControl::logfile | ( | const Pathname & | logfile_r,
|  | mode_t | mode_r )

Definition at line 898 of file LogControl.cc.

## ◆ logNothing()

void zypp::base::LogControl::logNothing | ( |  | ) |

Turn off logging.

Definition at line 937 of file LogControl.cc.

## ◆ logToStdErr()

void zypp::base::LogControl::logToStdErr | ( |  | ) |

Log to std::err.

Definition at line 945 of file LogControl.cc.

## ◆ emergencyShutdown()

void zypp::base::base::LogControl::emergencyShutdown | ( |  | ) |

will cause the log thread to exit and flush all sockets

Definition at line 953 of file LogControl.cc.

## ◆ notifyFork()

void zypp::base::LogControl::notifyFork | ( |  | ) |
| static

This will completely disable logging.

It is supposed to be called in the child process after fork() was called to shut down all logging completely.

Definition at line 958 of file LogControl.cc.

## ◆ logRawLine()

void zypp::base::LogControl::logRawLine | ( | std::string && | line | ) |

will push a line to the logthread without formatting it

Definition at line 963 of file LogControl.cc.

## ◆ getLineWriter()

shared_ptr< LogControl::LineWriter > zypp::base::LogControl::getLineWriter | ( |  | ) | const

Get the current LineWriter.

Definition at line 907 of file LogControl.cc.

## ◆ setLineWriter()

void zypp::base::LogControl::setLineWriter | ( | const shared_ptr< LineWriter > & | writer_r | ) |

Assign a LineWriter.

If you want to log the (formated) loglines by yourself. NULL turns off logging (same as logNothing)

See also
  log::LineWriter

Definition at line 916 of file LogControl.cc.

## Friends And Related Symbol Documentation

## ◆ operator<<

std::ostream & operator<< | ( | std::ostream & | str,
|  | const LogControl & | obj )
| friend

relates: LogControl Stream output

Definition at line 993 of file LogControl.cc.

The documentation for this class was generated from the following files:

- zypp-core/base/LogControl.h
- zypp-core/base/LogControl.cc