libzypp 17.38.15

LogControl.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <fstream>
14#include <string>
15#include <mutex>
16#include <map>
17
18#include <zypp-core/base/Logger.h>
19#include <zypp-core/base/LogControl.h>
20#include <zypp-core/base/ProfilingFormater.h>
21#include <zypp-core/base/PtrTypes.h>
22#include <zypp-core/base/String.h>
23#include <zypp-core/Date.h>
24#include <zypp-core/TriBool.h>
25#include <zypp-core/AutoDispose.h>
26
27#include <utility>
28#include <zypp-core/ng/io/Socket>
29#include <zypp-core/ng/io/SockAddr>
30#include <zypp-core/ng/base/EventLoop>
31#include <zypp-core/ng/base/EventDispatcher>
32#include <zypp-core/ng/base/Timer>
33#include <zypp-core/ng/base/private/linuxhelpers_p.h>
34#include <zypp-core/ng/thread/Wakeup>
35#include <zypp-core/ng/base/private/threaddata_p.h>
36#include <zypp-core/ng/base/SocketNotifier>
37
38#include <thread>
39#include <variant>
40#include <atomic>
41#include <csignal>
42
43 extern "C"
44{
45#include <sys/types.h>
46#include <sys/stat.h>
47#include <fcntl.h>
48#include <unistd.h>
49#include <dirent.h>
50}
51
52 using std::endl;
53
54std::once_flag flagReadEnvAutomatically;
55
56 namespace zypp
57{
58 constexpr std::string_view ZYPP_MAIN_THREAD_NAME( "Zypp-main" );
59
60 template<class> inline constexpr bool always_false_v = false;
61
66 class SpinLock {
67 public:
68 void lock () {
69 // acquire lock
70 while ( _atomicLock.test_and_set())
71 // Reschedule the current thread while we wait. Maybe, when it is our next turn, the lock is free again.
72 std::this_thread::yield();
73 }
74
75 void unlock() {
76 _atomicLock.clear();
77 }
78
79 private:
80 // we use a lock-free atomic flag here, so this lock can be safely obtained in a signal handler as well
81 std::atomic_flag _atomicLock = ATOMIC_FLAG_INIT;
82 };
83
84 class LogThread
85 {
86
87 public:
88 LogThread(const LogThread &) = delete;
89 LogThread(LogThread &&) = delete;
90 LogThread &operator=(const LogThread &) = delete;
91 LogThread &operator=(LogThread &&) = delete;
92
93 ~LogThread() { stop(); }
94
95 static LogThread &instance () {
96 static LogThread t;
97 return t;
98 }
99
100 void setLineWriter ( zypp::shared_ptr<log::LineWriter> writer ) {
101 std::lock_guard lk( _lineWriterLock );
102 _lineWriter = std::move(writer);
103 }
104
105 zypp::shared_ptr<log::LineWriter> getLineWriter () {
106 std::lock_guard lk( _lineWriterLock );
107 auto lw = _lineWriter;
108 return lw;
109 }
110
111 void stop () {
112 _stopSignal.notify();
113 if ( _thread.get_id() != std::this_thread::get_id() )
114 _thread.join();
115 }
116
117 std::thread::id threadId () {
118 return _thread.get_id();
119 }
120
121 static std::string sockPath () {
122 static std::string path = zypp::str::Format("zypp-logsocket-%1%") % getpid();
123 return path;
124 }
125
126 private:
127
128 LogThread ()
129 {
130 // Name the thread that started the logger, assuming it's the main thread.
131 zyppng::ThreadData::current().setName(ZYPP_MAIN_THREAD_NAME);
132 _thread = std::thread( [this] () {
133 workerMain();
134 });
135 }
136
137 void workerMain () {
138
139 // force the kernel to pick another thread to handle signals
140 zyppng::blockAllSignalsForCurrentThread();
141
142 zyppng::ThreadData::current().setName("Zypp-Log");
143
144 auto ev = zyppng::EventLoop::create();
145 auto server = zyppng::Socket::create( AF_UNIX, SOCK_STREAM, 0 );
146 auto stopNotifyWatch = _stopSignal.makeNotifier( );
147
148 std::vector<zyppng::Socket::Ptr> clients;
149
150 // bind to a abstract unix domain socket address, which means we do not need to care about cleaning it up
151 server->bind( std::make_shared<zyppng::UnixSockAddr>( sockPath(), true ) );
152 server->listen();
153
154 // wait for incoming connections from other threads
155 server->connectFunc( &zyppng::Socket::sigIncomingConnection, [&](){
156
157 auto cl = server->accept();
158 if ( !cl ) return;
159 clients.push_back( cl );
160
161 // wait until data is available, we operate line by line so we only
162 // log a string once we encounter \n
163 cl->connectFunc( &zyppng::Socket::sigReadyRead, [ this, sock = cl.get() ](){
164 auto writer = getLineWriter();
165 if ( !writer ) return;
166 while ( sock->canReadLine() ) {
167 auto br = sock->readLine();
168 writer->writeOut( std::string( br.data(), br.size() - 1 ) );
169 }
170 }, *cl);
171
172 // once a client disconnects we remove it from the std::vector so that the socket is not leaked
173 cl->connectFunc( &zyppng::Socket::sigDisconnected, [&clients, sock = std::weak_ptr(cl)](){
174 auto lock = sock.lock();
175 if ( !lock )
176 return;
177
178 auto idx = std::find_if( clients.begin(), clients.end(), [lock]( const auto &s ){ return lock.get() == s.get(); } );
179 clients.erase( idx );
180 });
181
182 });
183
184 stopNotifyWatch->connectFunc( &zyppng::SocketNotifier::sigActivated, [&ev]( const auto &, auto ) {
185 ev->quit();
186 });
187
188 ev->run();
189
190 // make sure we have written everything
191 auto writer = getLineWriter();
192 if ( writer ) {
193 for ( auto &sock : clients ){
194 auto br = sock->readLine();
195 while ( !br.empty() ) {
196 if ( br.back () == '\n' )
197 writer->writeOut( std::string( br.data(), br.size() - 1 ) );
198 else
199 writer->writeOut( std::string( br.data(), br.size() ) );
200
201 br = sock->readLine();
202 }
203 }
204 }
205 }
206
207 private:
208 std::thread _thread;
209 zyppng::Wakeup _stopSignal;
210
211 // since the public API uses boost::shared_ptr (via the alias zypp::shared_ptr) we can not use the atomic
212 // functionalities provided in std.
213 // this lock type can be used safely in signals
214 SpinLock _lineWriterLock;
215 // boost shared_ptr has a lock free implementation of reference counting so it can be used from signal handlers as well
216 shared_ptr<log::LineWriter> _lineWriter{ nullptr };
217 };
218
219 class LogClient
220 {
221 public:
222 LogClient(){
223 // make sure the thread is running
224 LogThread::instance();
225 }
226
227 LogClient(const LogClient &) = delete;
228 LogClient(LogClient &&) = delete;
229 LogClient &operator=(const LogClient &) = delete;
230 LogClient &operator=(LogClient &&) = delete;
231
232 ~LogClient() { if (_sockFD >= 0) ::close(_sockFD); }
233
238 bool ensureConnection () {
239 if ( _sockFD >= 0 )
240 return true;
241
242 _sockFD = ::socket( AF_UNIX, SOCK_STREAM, 0 );
243 if ( _sockFD == -1 )
244 return false;
245
246 zyppng::UnixSockAddr addr( LogThread::sockPath(), true );
247 return zyppng::trySocketConnection( _sockFD, addr, 100 );
248 }
249
253 void pushMessage ( std::string msg ) {
254 if ( inPushMessage ) {
255 return;
256 }
257
258 // make sure we do not end up in a busy loop
259 zypp::AutoDispose<bool *> res( &inPushMessage, [](auto val){
260 *val = false;
261 });
262 inPushMessage = true;
263
264 // if we are in the same thread as the Log worker we can directly push our messages out, no need to use the socket
265 if ( std::this_thread::get_id() == LogThread::instance().threadId() ) {
266 auto writer = LogThread::instance().getLineWriter();
267 if ( writer )
268 writer->writeOut( msg );
269 return;
270 }
271
272 if(!ensureConnection())
273 return;
274
275 if ( msg.back() != '\n' )
276 msg.push_back('\n');
277
278 size_t written = 0;
279 while ( written < msg.size() ) {
280 const auto res = zyppng::eintrSafeCall( ::send, _sockFD, msg.data() + written, msg.size() - written, MSG_NOSIGNAL );
281 if ( res == -1 ) {
282 //assume broken socket
283 ::close( _sockFD );
284 _sockFD = -1;
285 return;
286 }
287 written += res;
288 }
289 }
290
291 private:
292 int _sockFD = -1;
293 bool inPushMessage = false;
294 };
295
296 namespace debug
297 {
298 unsigned BlockTrace::_depth = 0;
299
300 BlockTrace::BlockTrace( const char * file_r, const char * fnc_r, int line_r, std::string msg_r )
301 : BlockTraceBase( file_r, fnc_r, line_r, std::move(msg_r) )
302 {
303 unsigned depth = _depth++;
304 zypp::base::logger::getStream( "BLOCK", zypp::base::logger::E_MIL, _file, _fnc, _line ) << "+++ (" << depth << ") " << _msg << endl;
305 }
306
307 BlockTrace::~BlockTrace()
308 {
309 unsigned depth = --_depth;
310 zypp::base::logger::getStream( "BLOCK", zypp::base::logger::E_MIL, _file, _fnc, _line ) << "--- (" << depth << ") " << _msg << endl;
311 }
312
313#ifndef ZYPP_NDEBUG
314 // Fg::Black: 30 Bg: 40 Attr::Normal: 22;27
315 // Fg::Red: 31 ... Attr::Bright: 1
316 // Fg::Green: 32 Attr::Reverse: 7
317 // Fg::Yellow: 33
318 // Fg::Blue: 34
319 // Fg::Magenta: 35
320 // Fg::Cyan: 36
321 // Fg::White: 37
322 // Fg::Default: 39
323 static constexpr std::string_view OO { "\033[0m" };
324 static constexpr std::string_view WH { "\033[37;40m" };
325 static constexpr std::string_view CY { "\033[36;40m" };
326 static constexpr std::string_view YE { "\033[33;1;40m" };
327 static constexpr std::string_view GR { "\033[32;40m" };
328 static constexpr std::string_view RE { "\033[31;1;40m" };
329 static constexpr std::string_view MA { "\033[35;40m" };
330
331 unsigned TraceLeave::_depth = 0;
332
333 std::string tracestr( char tag_r, unsigned depth_r, const std::string & msg_r, const char * file_r, const char * fnc_r, int line_r )
334 {
335 static str::Format fmt { "***%2d %s%c %s(%s):%d %s" };
336 fmt % depth_r %std::string(depth_r,'.') % tag_r % Pathname::basename(file_r) % fnc_r % line_r % msg_r;
337 return fmt;
338 }
339
340 TraceLeave::TraceLeave( const char * file_r, const char * fnc_r, int line_r, std::string msg_r )
341 : BlockTraceBase( file_r, fnc_r, line_r, std::move(msg_r) )
342 {
343 unsigned depth = _depth++;
344 const std::string & m { tracestr( '>',depth, _msg, _file,_fnc,_line ) };
345 Osd(L_USR("TRACE"),depth) << m << endl;
346 }
347
348 TraceLeave::~TraceLeave()
349 {
350 unsigned depth = --_depth;
351 const std::string & m { tracestr( '<',depth, _msg, _file,_fnc,_line ) };
352 Osd(L_USR("TRACE"),depth) << m << endl;
353 }
354
355 Osd::Osd( std::ostream & str, int i )
356 : _strout { std::cerr }
357 , _strlog { str }
358 { _strout << (i?WH:YE); }
359
360 Osd::~Osd()
361 { _strout << OO; }
362
363 Osd & Osd::operator<<( std::ostream& (*iomanip)( std::ostream& ) )
364 {
365 _strout << iomanip;
366 _strlog << iomanip;
367 return *this;
368 }
369
370 Osd & getOSD()
371 {
372 static Osd str { L_USR("OSD") };
373 return str;
374 }
375#endif // ZYPP_NDEBUG
376} // namespace debug
377
379 namespace log
380 {
381
382 StdoutLineWriter::StdoutLineWriter()
383 : StreamLineWriter( std::cout )
384 {}
385
386 StderrLineWriter::StderrLineWriter()
387 : StreamLineWriter( std::cerr )
388 {}
389
390 FileLineWriter::FileLineWriter( const Pathname & file_r, mode_t mode_r )
391 {
392 if ( file_r == Pathname("-") )
393 {
394 _str = &std::cerr;
395 }
396 else
397 {
398 if ( mode_r )
399 {
400 // not filesystem::assert_file as filesystem:: functions log,
401 // and this FileWriter is not yet in place.
402 int fd = ::open( file_r.c_str(), O_CREAT|O_EXCL, mode_r );
403 if ( fd != -1 )
404 ::close( fd );
405 }
406 // set unbuffered write
407 std::ofstream * fstr = 0;
408 _outs.reset( (fstr = new std::ofstream( file_r.asString().c_str(), std::ios_base::app )) );
409 fstr->rdbuf()->pubsetbuf(0,0);
410 _str = &(*fstr);
411 }
412 }
413
415 } // namespace log
416
417
419 namespace base
420 {
422 namespace logger
423 {
424
425 inline void putStream( const std::string & group_r, LogLevel level_r,
426 const char * file_r, const char * func_r, int line_r,
427 const std::string & buffer_r );
428
430 //
431 // CLASS NAME : Loglinebuf
432 //
433 class Loglinebuf : public std::streambuf {
434
435 public:
437 Loglinebuf( std::string group_r, LogLevel level_r )
438 : _group(std::move( group_r ))
439 , _level( level_r )
440 , _file( "" )
441 , _func( "" )
442 , _line( -1 )
443 {}
444
445 Loglinebuf(const Loglinebuf &) = default;
446 Loglinebuf(Loglinebuf &&) = default;
447 Loglinebuf &operator=(const Loglinebuf &) = default;
448 Loglinebuf &operator=(Loglinebuf &&) = default;
449
451 ~Loglinebuf() override
452 {
453 if ( !_buffer.empty() )
454 writeout( "\n", 1 );
455 }
456
458 void tagSet( const char * fil_r, const char * fnc_r, int lne_r )
459 {
460 _file = fil_r;
461 _func = fnc_r;
462 _line = lne_r;
463 }
464
465 private:
467 std::streamsize xsputn( const char * s, std::streamsize n ) override
468 { return writeout( s, n ); }
469
470 int overflow( int ch = EOF ) override
471 {
472 if ( ch != EOF )
473 {
474 char tmp = ch;
475 writeout( &tmp, 1 );
476 }
477 return 0;
478 }
479
480 virtual int writeout( const char* s, std::streamsize n )
481 {
482 //logger::putStream( _group, _level, _file, _func, _line, _buffer );
483 //return n;
484 if ( s && n )
485 {
486 const char * c = s;
487 for ( int i = 0; i < n; ++i, ++c )
488 {
489 if ( *c == '\n' ) {
490 _buffer += std::string( s, c-s );
491 logger::putStream( _group, _level, _file, _func, _line, _buffer );
492 _buffer = std::string();
493 s = c+1;
494 }
495 }
496 if ( s < c )
497 {
498 _buffer += std::string( s, c-s );
499 }
500 }
501 return n;
502 }
503
504 private:
505 std::string _group;
506 LogLevel _level;
507 const char * _file;
508 const char * _func;
509 int _line;
510 std::string _buffer;
511 };
512
514
516 //
517 // CLASS NAME : Loglinestream
518 //
519 class Loglinestream {
520
521 public:
523 Loglinestream( const std::string & group_r, LogLevel level_r )
524 : _mybuf( group_r, level_r )
525 , _mystream( &_mybuf )
526 {}
527
528 Loglinestream(const Loglinestream &) = delete;
529 Loglinestream(Loglinestream &&) = delete;
530 Loglinestream &operator=(const Loglinestream &) = delete;
531 Loglinestream &operator=(Loglinestream &&) = delete;
532
534 ~Loglinestream()
535 { _mystream.flush(); }
536
537 public:
539 std::ostream & getStream( const char * fil_r, const char * fnc_r, int lne_r )
540 {
541 _mybuf.tagSet( fil_r, fnc_r, lne_r );
542 return _mystream;
543 }
544
545 private:
546 Loglinebuf _mybuf;
547 std::ostream _mystream;
548 };
549
550
551 struct LogControlImpl;
552
553 /*
554 * Ugly hack to prevent the use of LogControlImpl when libzypp is shutting down.
555 * Due to the C++ standard, thread_local static instances are cleaned up before the first global static
556 * destructor is called. So all classes that use logging after that point in time would crash the
557 * application because it is accessing a variable that has already been destroyed.
558 */
559 int &logControlValidFlag() {
560 // We are using a POD flag that does not have a destructor,
561 // to flag if the thread_local destructors were already executed.
562 // Since TLS data is stored in a segment that is available until the thread ceases to exist it should still be readable
563 // after thread_local c++ destructors were already executed. Or so I hope.
564 static thread_local int logControlValid = 0;
565 return logControlValid;
566 }
567
569 //
570 // CLASS NAME : LogControlImpl
571 //
581 struct LogControlImpl
582 {
583 public:
584 bool isExcessive() const { return _excessive; }
585
586 void excessive( bool onOff_r )
587 { _excessive = onOff_r; }
588
589
591 bool hideThreadName() const
592 {
593 if ( indeterminate(_hideThreadName) )
594 _hideThreadName = ( zyppng::ThreadData::current().name() == ZYPP_MAIN_THREAD_NAME );
595 return bool(_hideThreadName);
596 }
597
598 void hideThreadName( bool onOff_r )
599 { _hideThreadName = onOff_r; }
600
602 static bool instanceHideThreadName()
603 {
604 auto impl = LogControlImpl::instance();
605 return impl ? impl->hideThreadName() : false;
606 }
607
608 static void instanceHideThreadName( bool onOff_r )
609 {
610 auto impl = LogControlImpl::instance();
611 if ( impl ) impl->hideThreadName( onOff_r );
612 }
613
615 static bool instanceLogToPPID( )
616 {
617 auto impl = LogControlImpl::instance();
618 return impl ? impl->_logToPPIDMode : false;
619 }
620
622 static void instanceSetLogToPPID( bool onOff_r )
623 {
624 auto impl = LogControlImpl::instance();
625 if ( impl )
626 impl->_logToPPIDMode = onOff_r;
627 }
628
630 void setLineWriter( const shared_ptr<LogControl::LineWriter> & writer_r )
631 { LogThread::instance().setLineWriter( writer_r ); }
632
633 shared_ptr<LogControl::LineWriter> getLineWriter() const
634 { return LogThread::instance().getLineWriter(); }
635
637 void setLineFormater( const shared_ptr<LogControl::LineFormater> & format_r )
638 {
639 if ( format_r )
640 _lineFormater = format_r;
641 else
642 _lineFormater.reset( new LogControl::LineFormater );
643 }
644
645 void logfile( const Pathname & logfile_r, mode_t mode_r = 0640 )
646 {
647 if ( logfile_r.empty() )
648 setLineWriter( shared_ptr<LogControl::LineWriter>() );
649 else if ( logfile_r == Pathname( "-" ) )
650 setLineWriter( shared_ptr<LogControl::LineWriter>(new log::StderrLineWriter) );
651 else
652 setLineWriter( shared_ptr<LogControl::LineWriter>(new log::FileLineWriter(logfile_r, mode_r)) );
653 }
654
655 private:
656 LogClient _logClient;
657 std::ostream _no_stream;
658 bool _excessive;
659 bool _logToPPIDMode = false;
660 mutable TriBool _hideThreadName = indeterminate;
661
662 shared_ptr<LogControl::LineFormater> _lineFormater;
663
664 public:
666 std::ostream & getStream( const std::string & group_r,
667 LogLevel level_r,
668 const char * file_r,
669 const char * func_r,
670 const int line_r )
671 {
672 if ( ! getLineWriter() )
673 return _no_stream;
674 if ( level_r == E_XXX && !_excessive )
675 return _no_stream;
676
677 if ( !_streamtable[group_r][level_r] )
678 {
679 _streamtable[group_r][level_r].reset( new Loglinestream( group_r, level_r ) );
680 }
681 std::ostream & ret( _streamtable[group_r][level_r]->getStream( file_r, func_r, line_r ) );
682 if ( !ret )
683 {
684 ret.clear();
685 ret << "---<RESET LOGSTREAM FROM FAILED STATE]" << endl;
686 }
687 return ret;
688 }
689
690 void putRawLine ( std::string &&line ) {
691 _logClient.pushMessage( std::move(line) );
692 }
693
695 void putStream( const std::string & group_r,
696 LogLevel level_r,
697 const char * file_r,
698 const char * func_r,
699 int line_r,
700 const std::string & message_r )
701 {
702 _logClient.pushMessage( _lineFormater->format( group_r, level_r,
703 file_r, func_r, line_r,
704 message_r ) );
705 }
706
707 private:
708 using StreamPtr = shared_ptr<Loglinestream>;
709 using StreamSet = std::map<LogLevel, StreamPtr>;
710 using StreamTable = std::map<std::string, StreamSet>;
712 StreamTable _streamtable;
713 zyppng::Socket::Ptr _sock;
714
715 private:
716
717 void readEnvVars () {
718 if ( getenv("ZYPP_LOGFILE") )
719 logfile( getenv("ZYPP_LOGFILE") );
720
721 if ( getenv("ZYPP_PROFILING") )
722 {
723 shared_ptr<LogControl::LineFormater> formater(new ProfilingFormater);
724 setLineFormater(formater);
725 }
726 }
727
730 LogControlImpl()
731 : _no_stream( NULL )
732 , _excessive( getenv("ZYPP_FULLLOG") )
733 , _lineFormater( new LogControl::LineFormater )
734 {
735 logControlValidFlag() = 1;
736 std::call_once( flagReadEnvAutomatically, &LogControlImpl::readEnvVars, this);
737
738 // make sure the LogControl is invalidated when we fork
739 pthread_atfork( nullptr, nullptr, &LogControl::notifyFork );
740 }
741
742 public:
743
744 LogControlImpl(const LogControlImpl &) = delete;
745 LogControlImpl(LogControlImpl &&) = delete;
746 LogControlImpl &operator=(const LogControlImpl &) = delete;
747 LogControlImpl &operator=(LogControlImpl &&) = delete;
748
749 ~LogControlImpl()
750 {
751 logControlValidFlag() = 0;
752 }
753
760 static LogControlImpl *instance();
761 };
762
763
764 // 'THE' LogControlImpl singleton
765 inline LogControlImpl *LogControlImpl::instance()
766 {
767 thread_local static LogControlImpl _instance;
768 if ( logControlValidFlag() > 0 )
769 return &_instance;
770 return nullptr;
771 }
772
774
776 inline std::ostream & operator<<( std::ostream & str, const LogControlImpl & )
777 {
778 return str << "LogControlImpl";
779 }
780
782 //
783 // Access from logger::
784 //
786
787 std::ostream & getStream( const char * group_r,
788 LogLevel level_r,
789 const char * file_r,
790 const char * func_r,
791 const int line_r )
792 {
793 static std::ostream nstream(NULL);
794 auto control = LogControlImpl::instance();
795 if ( !control || !group_r || strlen(group_r ) == 0 ) {
796 return nstream;
797 }
798
799
800
801 return control->getStream( group_r,
802 level_r,
803 file_r,
804 func_r,
805 line_r );
806 }
807
809 inline void putStream( const std::string & group_r, LogLevel level_r,
810 const char * file_r, const char * func_r, int line_r,
811 const std::string & buffer_r )
812 {
813 auto control = LogControlImpl::instance();
814 if ( !control )
815 return;
816
817 control->putStream( group_r, level_r,
818 file_r, func_r, line_r,
819 buffer_r );
820 }
821
822 bool isExcessive()
823 {
824 auto impl = LogControlImpl::instance();
825 if ( !impl )
826 return false;
827 return impl->isExcessive();
828 }
829
831 } // namespace logger
832
833
834 using logger::LogControlImpl;
835
837 // LineFormater
839 std::string LogControl::LineFormater::format( const std::string & group_r,
840 logger::LogLevel level_r,
841 const char * file_r,
842 const char * func_r,
843 int line_r,
844 const std::string & message_r )
845 {
846 static char hostname[1024];
847 static char nohostname[] = "unknown";
848 std::string now( Date::now().form( "%Y-%m-%d %H:%M:%S" ) );
849 std::string ret;
850
851 const bool logToPPID = LogControlImpl::instanceLogToPPID();
852 if ( !logToPPID && LogControlImpl::instanceHideThreadName() )
853 ret = str::form( "%s <%d> %s(%d) [%s] %s(%s):%d %s",
854 now.c_str(), level_r,
855 ( gethostname( hostname, 1024 ) ? nohostname : hostname ),
856 getpid(),
857 group_r.c_str(),
858 file_r, func_r, line_r,
859 message_r.c_str() );
860 else
861 ret = str::form( "%s <%d> %s(%d) [%s] %s(%s):%d {T:%s} %s",
862 now.c_str(), level_r,
863 ( gethostname( hostname, 1024 ) ? nohostname : hostname ),
864 logToPPID ? getppid() : getpid(),
865 group_r.c_str(),
866 file_r, func_r, line_r,
867 zyppng::ThreadData::current().name().c_str(),
868 message_r.c_str() );
869 return ret;
870 }
871
872 std::string LogControl::JournalLineFormater::format( const std::string & group_r,
873 logger::LogLevel level_r,
874 const char * file_r,
875 const char * func_r,
876 int line_r,
877 const std::string & message_r )
878 {
879 std::string ret;
880 if ( not LogControlImpl::instanceLogToPPID() && LogControlImpl::instanceHideThreadName() )
881 ret = str::form( "<%d> [%s] %s(%s):%d %s",
882 level_r, group_r.c_str(),
883 file_r, func_r, line_r,
884 message_r.c_str() );
885 else
886 ret = str::form( "<%d> [%s] %s(%s):%d {T:%s} %s",
887 level_r, group_r.c_str(),
888 file_r, func_r, line_r,
889 zyppng::ThreadData::current().name().c_str(),
890 message_r.c_str() );
891 return ret;
892 }
893
894 //
895 // CLASS NAME : LogControl
896 // Forward to LogControlImpl singleton.
897 //
899
900
901 void LogControl::logfile( const Pathname & logfile_r )
902 {
903 auto impl = LogControlImpl::instance();
904 if ( !impl )
905 return;
906
907 impl->logfile( logfile_r );
908 }
909
910 void LogControl::logfile( const Pathname & logfile_r, mode_t mode_r )
911 {
912 auto impl = LogControlImpl::instance();
913 if ( !impl )
914 return;
915
916 impl->logfile( logfile_r, mode_r );
917 }
918
919 shared_ptr<LogControl::LineWriter> LogControl::getLineWriter() const
920 {
921 auto impl = LogControlImpl::instance();
922 if ( !impl )
923 return nullptr;
924
925 return impl->getLineWriter();
926 }
927
928 void LogControl::setLineWriter( const shared_ptr<LineWriter> & writer_r )
929 {
930 auto impl = LogControlImpl::instance();
931 if ( !impl )
932 return;
933 impl->setLineWriter( writer_r );
934 }
935
936 void LogControl::setLineFormater( const shared_ptr<LineFormater> & formater_r )
937 {
938 auto impl = LogControlImpl::instance();
939 if ( !impl )
940 return;
941 impl->setLineFormater( formater_r );
942 }
943
944 void LogControl::enableLogForwardingMode(bool enable)
945 {
946 LogControlImpl::instanceSetLogToPPID ( enable );
947 }
948
949 void LogControl::logNothing()
950 {
951 auto impl = LogControlImpl::instance();
952 if ( !impl )
953 return;
954 impl->setLineWriter( shared_ptr<LineWriter>() );
955 }
956
957 void LogControl::logToStdErr()
958 {
959 auto impl = LogControlImpl::instance();
960 if ( !impl )
961 return;
962 impl->setLineWriter( shared_ptr<LineWriter>( new log::StderrLineWriter ) );
963 }
964
965 void base::LogControl::emergencyShutdown()
966 {
967 LogThread::instance().stop();
968 }
969
970 void LogControl::notifyFork()
971 {
972 logger::logControlValidFlag () = 0;
973 }
974
975 void LogControl::logRawLine ( std::string &&line )
976 {
977 LogControlImpl::instance ()->putRawLine ( std::move(line) );
978 }
979
981 //
982 // LogControl::TmpExcessive
983 //
985 LogControl::TmpExcessive::TmpExcessive()
986 {
987 auto impl = LogControlImpl::instance();
988 if ( !impl )
989 return;
990 impl->excessive( true );
991 }
992 LogControl::TmpExcessive::~TmpExcessive()
993 {
994 auto impl = LogControlImpl::instance();
995 if ( !impl )
996 return;
997 impl->excessive( false );
998 }
999
1000 /******************************************************************
1001 **
1002 ** FUNCTION NAME : operator<<
1003 ** FUNCTION TYPE : std::ostream &
1004 */
1005 std::ostream & operator<<( std::ostream & str, const LogControl & )
1006 {
1007 auto impl = LogControlImpl::instance();
1008 if ( !impl )
1009 return str;
1010 return str << *impl;
1011 }
1012
1014 } // namespace base
1017} // namespace zypp
AutoDispose.h
Date.h
flagReadEnvAutomatically
std::once_flag flagReadEnvAutomatically
Definition LogControl.cc:54
LogControl.h
Logger.h
L_USR
#define L_USR(GROUP)
Definition Logger.h:144
ProfilingFormater.h
PtrTypes.h
String.h
TriBool.h
bool
shared_ptr
zypp::AutoDispose
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
zypp::Date::now
static Date now()
Return the current time.
Definition Date.h:78
zypp::LogClient
Definition LogControl.cc:220
zypp::LogClient::inPushMessage
bool inPushMessage
Definition LogControl.cc:293
zypp::LogClient::_sockFD
int _sockFD
Definition LogControl.cc:292
zypp::LogClient::ensureConnection
bool ensureConnection()
Definition LogControl.cc:238
zypp::LogClient::LogClient
LogClient(LogClient &&)=delete
zypp::LogClient::LogClient
LogClient(const LogClient &)=delete
zypp::LogClient::operator=
LogClient & operator=(const LogClient &)=delete
zypp::LogClient::~LogClient
~LogClient()
Definition LogControl.cc:232
zypp::LogClient::LogClient
LogClient()
Definition LogControl.cc:222
zypp::LogClient::operator=
LogClient & operator=(LogClient &&)=delete
zypp::LogClient::pushMessage
void pushMessage(std::string msg)
Definition LogControl.cc:253
zypp::LogThread::_lineWriter
shared_ptr< log::LineWriter > _lineWriter
Definition LogControl.cc:216
zypp::LogThread::stop
void stop()
Definition LogControl.cc:111
zypp::LogThread::_thread
std::thread _thread
Definition LogControl.cc:208
zypp::LogThread::operator=
LogThread & operator=(const LogThread &)=delete
zypp::LogThread::getLineWriter
zypp::shared_ptr< log::LineWriter > getLineWriter()
Definition LogControl.cc:105
zypp::LogThread::_stopSignal
zyppng::Wakeup _stopSignal
Definition LogControl.cc:209
zypp::LogThread::LogThread
LogThread(const LogThread &)=delete
zypp::LogThread::workerMain
void workerMain()
Definition LogControl.cc:137
zypp::LogThread::threadId
std::thread::id threadId()
Definition LogControl.cc:117
zypp::LogThread::LogThread
LogThread(LogThread &&)=delete
zypp::LogThread::operator=
LogThread & operator=(LogThread &&)=delete
zypp::LogThread::_lineWriterLock
SpinLock _lineWriterLock
Definition LogControl.cc:214
zypp::LogThread::LogThread
LogThread()
Definition LogControl.cc:128
zypp::LogThread::setLineWriter
void setLineWriter(zypp::shared_ptr< log::LineWriter > writer)
Definition LogControl.cc:100
zypp::LogThread::instance
static LogThread & instance()
Definition LogControl.cc:95
zypp::LogThread::sockPath
static std::string sockPath()
Definition LogControl.cc:121
zypp::LogThread::~LogThread
~LogThread()
Definition LogControl.cc:93
zypp::Pathname::Pathname
Pathname()
Default ctor: an empty path.
Definition Pathname.h:51
zypp::Pathname::basename
std::string basename() const
Return the last component of this path.
Definition Pathname.h:137
zypp::SpinLock
Definition LogControl.cc:66
zypp::SpinLock::_atomicLock
std::atomic_flag _atomicLock
Definition LogControl.cc:81
zypp::SpinLock::lock
void lock()
Definition LogControl.cc:68
zypp::SpinLock::unlock
void unlock()
Definition LogControl.cc:75
zypp::base::LogControl
Maintain logfile related options.
Definition LogControl.h:97
zypp::base::LogControl::operator<<
friend std::ostream & operator<<(std::ostream &str, const LogControl &obj)
relates: LogControl Stream output
Definition LogControl.cc:1005
zypp::base::LogControl::LogControl
LogControl()
Default ctor: Singleton.
Definition LogControl.h:228
zypp::base::LogControl::getLineWriter
shared_ptr< LineWriter > getLineWriter() const
Get the current LineWriter.
Definition LogControl.cc:919
zypp::base::LogControl::setLineWriter
void setLineWriter(const shared_ptr< LineWriter > &writer_r)
Assign a LineWriter.
Definition LogControl.cc:928
zypp::base::LogControl::logToStdErr
void logToStdErr()
Log to std::err.
Definition LogControl.cc:957
zypp::base::LogControl::logRawLine
void logRawLine(std::string &&line)
will push a line to the logthread without formatting it
Definition LogControl.cc:975
zypp::base::LogControl::logNothing
void logNothing()
Turn off logging.
Definition LogControl.cc:949
zypp::base::LogControl::notifyFork
static void notifyFork()
This will completely disable logging.
Definition LogControl.cc:970
zypp::base::LogControl::setLineFormater
void setLineFormater(const shared_ptr< LineFormater > &formater_r)
Assign a LineFormater.
Definition LogControl.cc:936
zypp::base::LogControl::enableLogForwardingMode
void enableLogForwardingMode(bool enable=true)
Definition LogControl.cc:944
zypp::base::LogControl::logfile
void logfile(const Pathname &logfile_r)
Set path for the logfile.
Definition LogControl.cc:901
zypp::base::LogControl::emergencyShutdown
void emergencyShutdown()
will cause the log thread to exit and flush all sockets
Definition LogControl.cc:965
zypp::base::logger::Loglinebuf
Definition LogControl.cc:433
zypp::base::logger::Loglinebuf::overflow
int overflow(int ch=EOF) override
Definition LogControl.cc:470
zypp::base::logger::Loglinebuf::xsputn
std::streamsize xsputn(const char *s, std::streamsize n) override
Definition LogControl.cc:467
zypp::base::logger::Loglinebuf::_buffer
std::string _buffer
Definition LogControl.cc:510
zypp::base::logger::Loglinebuf::_func
const char * _func
Definition LogControl.cc:508
zypp::base::logger::Loglinebuf::~Loglinebuf
~Loglinebuf() override
Definition LogControl.cc:451
zypp::base::logger::Loglinebuf::Loglinebuf
Loglinebuf(const Loglinebuf &)=default
zypp::base::logger::Loglinebuf::Loglinebuf
Loglinebuf(std::string group_r, LogLevel level_r)
Definition LogControl.cc:437
zypp::base::logger::Loglinebuf::Loglinebuf
Loglinebuf(Loglinebuf &&)=default
zypp::base::logger::Loglinebuf::_group
std::string _group
Definition LogControl.cc:505
zypp::base::logger::Loglinebuf::_level
LogLevel _level
Definition LogControl.cc:506
zypp::base::logger::Loglinebuf::operator=
Loglinebuf & operator=(const Loglinebuf &)=default
zypp::base::logger::Loglinebuf::_file
const char * _file
Definition LogControl.cc:507
zypp::base::logger::Loglinebuf::tagSet
void tagSet(const char *fil_r, const char *fnc_r, int lne_r)
Definition LogControl.cc:458
zypp::base::logger::Loglinebuf::writeout
virtual int writeout(const char *s, std::streamsize n)
Definition LogControl.cc:480
zypp::base::logger::Loglinebuf::_line
int _line
Definition LogControl.cc:509
zypp::base::logger::Loglinebuf::operator=
Loglinebuf & operator=(Loglinebuf &&)=default
zypp::base::logger::Loglinestream::~Loglinestream
~Loglinestream()
Definition LogControl.cc:534
zypp::base::logger::Loglinestream::_mystream
std::ostream _mystream
Definition LogControl.cc:547
zypp::base::logger::Loglinestream::Loglinestream
Loglinestream(const std::string &group_r, LogLevel level_r)
Definition LogControl.cc:523
zypp::base::logger::Loglinestream::Loglinestream
Loglinestream(const Loglinestream &)=delete
zypp::base::logger::Loglinestream::operator=
Loglinestream & operator=(const Loglinestream &)=delete
zypp::base::logger::Loglinestream::getStream
std::ostream & getStream(const char *fil_r, const char *fnc_r, int lne_r)
Definition LogControl.cc:539
zypp::base::logger::Loglinestream::Loglinestream
Loglinestream(Loglinestream &&)=delete
zypp::base::logger::Loglinestream::_mybuf
Loglinebuf _mybuf
Definition LogControl.cc:546
zypp::base::logger::Loglinestream::operator=
Loglinestream & operator=(Loglinestream &&)=delete
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::filesystem::Pathname::c_str
const char * c_str() const
String representation.
Definition Pathname.h:113
zypp::filesystem::Pathname::asString
const std::string & asString() const
String representation.
Definition Pathname.h:94
zypp::filesystem::Pathname::empty
bool empty() const
Test for an empty path.
Definition Pathname.h:117
zyppng::EventLoop::create
static Ptr create(GMainContext *ctx=nullptr)
Definition eventloop_glib.cc:29
zyppng::IODevice::sigReadyRead
SignalProxy< void()> sigReadyRead()
Definition iodevice.cc:368
zyppng::SocketNotifier::sigActivated
SignalProxy< void(const SocketNotifier &sock, int evTypes)> sigActivated()
Definition socketnotifier.cc:76
zyppng::Socket::create
static Ptr create(int domain, int type, int protocol)
Definition socket.cc:458
zyppng::Socket::sigDisconnected
SignalProxy< void()> sigDisconnected()
Definition socket.cc:882
zyppng::Socket::sigIncomingConnection
SignalProxy< void()> sigIncomingConnection()
Definition socket.cc:872
zyppng::Socket::Ptr
std::shared_ptr< Socket > Ptr
Definition socket.h:71
zyppng::UnixSockAddr
Definition sockaddr.h:36
zyppng::Wakeup
Definition wakeup.h:23
zyppng::Wakeup::makeNotifier
std::shared_ptr< SocketNotifier > makeNotifier(const bool enabled=true) const
Definition wakeup.cpp:39
zyppng::Wakeup::notify
void notify()
Definition wakeup.cpp:23
zypp::TriBool
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
linuxhelpers_p.h
form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
std
Definition ansi.h:855
str
String related utilities and Regular expression matching.
zypp::base::logger
Definition LogControl.cc:423
zypp::base::logger::logControlValidFlag
int & logControlValidFlag()
Definition LogControl.cc:559
zypp::base::logger::operator<<
std::ostream & operator<<(std::ostream &str, const LogControlImpl &)
relates: LogControlImpl Stream output
Definition LogControl.cc:776
zypp::base::logger::putStream
void putStream(const std::string &group_r, LogLevel level_r, const char *file_r, const char *func_r, int line_r, const std::string &buffer_r)
That's what Loglinebuf calls.
Definition LogControl.cc:809
zypp::base::logger::LogLevel
LogLevel
Definition of log levels.
Definition Logger.h:186
zypp::base::logger::E_XXX
@ E_XXX
Excessive logging.
Definition Logger.h:187
zypp::base::logger::E_MIL
@ E_MIL
Milestone.
Definition Logger.h:189
zypp::base::logger::isExcessive
bool isExcessive()
Definition LogControl.cc:822
zypp::base::logger::getStream
std::ostream & getStream(const char *group_r, LogLevel level_r, const char *file_r, const char *func_r, const int line_r)
Return a log stream to write on.
Definition LogControl.cc:787
zypp::base
Definition Random.cc:7
zypp::debug
Definition Debug.h:31
zypp::debug::getOSD
Osd & getOSD()
Definition LogControl.cc:370
zypp::debug::WH
static constexpr std::string_view WH
Definition LogControl.cc:324
zypp::debug::OO
static constexpr std::string_view OO
Definition LogControl.cc:323
zypp::debug::YE
static constexpr std::string_view YE
Definition LogControl.cc:326
zypp::debug::CY
static constexpr std::string_view CY
Definition LogControl.cc:325
zypp::debug::GR
static constexpr std::string_view GR
Definition LogControl.cc:327
zypp::debug::tracestr
std::string tracestr(char tag_r, unsigned depth_r, const std::string &msg_r, const char *file_r, const char *fnc_r, int line_r)
Definition LogControl.cc:333
zypp::debug::MA
static constexpr std::string_view MA
Definition LogControl.cc:329
zypp::debug::RE
static constexpr std::string_view RE
Definition LogControl.cc:328
zypp::iomanip
Definition LogTools.h:453
zypp::log
Definition LogControl.cc:380
zypp::str::form
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Definition String.cc:39
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::always_false_v
constexpr bool always_false_v
Definition LogControl.cc:60
zypp::ZYPP_MAIN_THREAD_NAME
constexpr std::string_view ZYPP_MAIN_THREAD_NAME("Zypp-main")
zyppng::blockAllSignalsForCurrentThread
bool blockAllSignalsForCurrentThread()
Definition linuxhelpers.cc:15
zyppng::trySocketConnection
bool trySocketConnection(int &sockFD, const SockAddr &addr, uint64_t timeout)
Definition linuxhelpers.cc:34
zyppng::eintrSafeCall
auto eintrSafeCall(Fun &&function, Args &&... args)
Definition linuxhelpers_p.h:50
zypp::base::LogControlImpl::instance
static LogControlImpl * instance()
The LogControlImpl singleton.
Definition LogControl.cc:765
zypp::base::LogControlImpl::readEnvVars
void readEnvVars()
Definition LogControl.cc:717
zypp::base::LogControlImpl::instanceHideThreadName
static bool instanceHideThreadName()
Definition LogControl.cc:602
zypp::base::LogControlImpl::LogControlImpl
LogControlImpl()
Singleton ctor.
Definition LogControl.cc:730
zypp::base::LogControlImpl::instanceSetLogToPPID
static void instanceSetLogToPPID(bool onOff_r)
Definition LogControl.cc:622
zypp::base::LogControlImpl::instanceLogToPPID
static bool instanceLogToPPID()
Hint for formatter wether we forward all logs to a parents log.
Definition LogControl.cc:615
zypp::base::LogControl::JournalLineFormater::format
std::string format(const std::string &, logger::LogLevel, const char *, const char *, int, const std::string &) override
Definition LogControl.cc:872
zypp::base::LogControl::LineFormater
If you want to format loglines by yourself, derive from this, and overload format.
Definition LogControl.h:115
zypp::base::LogControl::LineFormater::format
virtual std::string format(const std::string &, logger::LogLevel, const char *, const char *, int, const std::string &)
Definition LogControl.cc:839
zypp::base::LogControl::TmpExcessive::~TmpExcessive
~TmpExcessive()
Definition LogControl.cc:992
zypp::base::LogControl::TmpExcessive::TmpExcessive
TmpExcessive()
Definition LogControl.cc:985
zypp::base::ProfilingFormater
Definition ProfilingFormater.h:27
zypp::base::logger::LogControlImpl
LogControl implementation (thread_local Singleton).
Definition LogControl.cc:582
zypp::base::logger::LogControlImpl::_excessive
bool _excessive
Definition LogControl.cc:658
zypp::base::logger::LogControlImpl::putRawLine
void putRawLine(std::string &&line)
Definition LogControl.cc:690
zypp::base::logger::LogControlImpl::setLineWriter
void setLineWriter(const shared_ptr< LogControl::LineWriter > &writer_r)
NULL _lineWriter indicates no loggin.
Definition LogControl.cc:630
zypp::base::logger::LogControlImpl::instance
static LogControlImpl * instance()
The LogControlImpl singleton.
Definition LogControl.cc:765
zypp::base::logger::LogControlImpl::readEnvVars
void readEnvVars()
Definition LogControl.cc:717
zypp::base::logger::LogControlImpl::instanceHideThreadName
static bool instanceHideThreadName()
Definition LogControl.cc:602
zypp::base::logger::LogControlImpl::~LogControlImpl
~LogControlImpl()
Definition LogControl.cc:749
zypp::base::logger::LogControlImpl::LogControlImpl
LogControlImpl(LogControlImpl &&)=delete
zypp::base::logger::LogControlImpl::operator=
LogControlImpl & operator=(const LogControlImpl &)=delete
zypp::base::logger::LogControlImpl::LogControlImpl
LogControlImpl()
Singleton ctor.
Definition LogControl.cc:730
zypp::base::logger::LogControlImpl::instanceHideThreadName
static void instanceHideThreadName(bool onOff_r)
Definition LogControl.cc:608
zypp::base::logger::LogControlImpl::isExcessive
bool isExcessive() const
Definition LogControl.cc:584
zypp::base::logger::LogControlImpl::instanceSetLogToPPID
static void instanceSetLogToPPID(bool onOff_r)
Definition LogControl.cc:622
zypp::base::logger::LogControlImpl::_streamtable
StreamTable _streamtable
one streambuffer per group and level
Definition LogControl.cc:712
zypp::base::logger::LogControlImpl::instanceLogToPPID
static bool instanceLogToPPID()
Hint for formatter wether we forward all logs to a parents log.
Definition LogControl.cc:615
zypp::base::logger::LogControlImpl::LogControlImpl
LogControlImpl(const LogControlImpl &)=delete
zypp::base::logger::LogControlImpl::excessive
void excessive(bool onOff_r)
Definition LogControl.cc:586
zypp::base::logger::LogControlImpl::StreamTable
std::map< std::string, StreamSet > StreamTable
Definition LogControl.cc:710
zypp::base::logger::LogControlImpl::_logToPPIDMode
bool _logToPPIDMode
Hint for formatter to use the PPID and always show the thread name.
Definition LogControl.cc:659
zypp::base::logger::LogControlImpl::setLineFormater
void setLineFormater(const shared_ptr< LogControl::LineFormater > &format_r)
Assert _lineFormater is not NULL.
Definition LogControl.cc:637
zypp::base::logger::LogControlImpl::getStream
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).
Definition LogControl.cc:666
zypp::base::logger::LogControlImpl::logfile
void logfile(const Pathname &logfile_r, mode_t mode_r=0640)
Definition LogControl.cc:645
zypp::base::logger::LogControlImpl::getLineWriter
shared_ptr< LogControl::LineWriter > getLineWriter() const
Definition LogControl.cc:633
zypp::base::logger::LogControlImpl::StreamSet
std::map< LogLevel, StreamPtr > StreamSet
Definition LogControl.cc:709
zypp::base::logger::LogControlImpl::_lineFormater
shared_ptr< LogControl::LineFormater > _lineFormater
Definition LogControl.cc:662
zypp::base::logger::LogControlImpl::operator=
LogControlImpl & operator=(LogControlImpl &&)=delete
zypp::base::logger::LogControlImpl::hideThreadName
bool hideThreadName() const
Hint for Formater whether to hide the thread name.
Definition LogControl.cc:591
zypp::base::logger::LogControlImpl::putStream
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.
Definition LogControl.cc:695
zypp::base::logger::LogControlImpl::_no_stream
std::ostream _no_stream
Definition LogControl.cc:657
zypp::base::logger::LogControlImpl::hideThreadName
void hideThreadName(bool onOff_r)
Definition LogControl.cc:598
zypp::base::logger::LogControlImpl::_sock
zyppng::Socket::Ptr _sock
Definition LogControl.cc:713
zypp::base::logger::LogControlImpl::_logClient
LogClient _logClient
Definition LogControl.cc:656
zypp::base::logger::LogControlImpl::_hideThreadName
TriBool _hideThreadName
Hint for Formater whether to hide the thread name.
Definition LogControl.cc:660
zypp::base::logger::LogControlImpl::StreamPtr
shared_ptr< Loglinestream > StreamPtr
Definition LogControl.cc:708
zypp::debug::BlockTraceBase::_fnc
const char * _fnc
Definition Logger.h:36
zypp::debug::BlockTraceBase::_msg
std::string _msg
Definition Logger.h:38
zypp::debug::BlockTraceBase::BlockTraceBase
BlockTraceBase(const BlockTraceBase &)=delete
zypp::debug::BlockTraceBase::_file
const char * _file
Definition Logger.h:35
zypp::debug::BlockTraceBase::_line
int _line
Definition Logger.h:37
zypp::debug::BlockTrace::BlockTrace
BlockTrace(const BlockTrace &)=delete
zypp::debug::BlockTrace::~BlockTrace
~BlockTrace()
Definition LogControl.cc:307
zypp::debug::BlockTrace::_depth
static unsigned _depth
Definition Logger.h:49
zypp::debug::Osd
Definition Logger.h:75
zypp::debug::Osd::_strlog
std::ostream & _strlog
Definition Logger.h:91
zypp::debug::Osd::Osd
Osd(std::ostream &, int=0)
Definition LogControl.cc:355
zypp::debug::Osd::_strout
std::ostream & _strout
Definition Logger.h:90
zypp::debug::Osd::operator<<
Osd & operator<<(Tp &&val)
Definition Logger.h:80
zypp::debug::Osd::~Osd
~Osd()
Definition LogControl.cc:360
zypp::debug::TraceLeave::TraceLeave
TraceLeave(const TraceLeave &)=delete
zypp::debug::TraceLeave::~TraceLeave
~TraceLeave()
Definition LogControl.cc:348
zypp::debug::TraceLeave::_depth
static unsigned _depth
Definition Logger.h:68
zypp::log::FileLineWriter
LineWriter to file.
Definition LogControl.h:73
zypp::log::FileLineWriter::_outs
shared_ptr< void > _outs
Definition LogControl.h:76
zypp::log::FileLineWriter::FileLineWriter
FileLineWriter(const Pathname &file_r, mode_t mode_r=0)
Definition LogControl.cc:390
zypp::log::StderrLineWriter
LineWriter to stderr.
Definition LogControl.h:64
zypp::log::StderrLineWriter::StderrLineWriter
StderrLineWriter()
Definition LogControl.cc:386
zypp::log::StdoutLineWriter::StdoutLineWriter
StdoutLineWriter()
Definition LogControl.cc:382
zypp::log::StreamLineWriter::_str
std::ostream * _str
Definition LogControl.h:53
zypp::log::StreamLineWriter::StreamLineWriter
StreamLineWriter(std::ostream &str_r)
Definition LogControl.h:46
zypp::str::Format
Convenient building of std::string with boost::format.
Definition String.h:254
zyppng::ThreadData::setName
void setName(T &&name)
Definition threaddata_p.h:20
zyppng::ThreadData::current
static ZYPP_API ThreadData & current()
Definition threaddata.cc:16
zyppng::ThreadData::name
const std::string & name() const
Definition threaddata.cc:22
threaddata_p.h