|
reSIProcate/stack
9694
|
#include "rutil/Logger.hxx"#include "rutil/Data.hxx"#include "rutil/ThreadIf.hxx"#include "rutil/Timer.hxx"
Go to the source code of this file.
Classes | |
| class | LogThread |
| class | ExampleExternalLogger |
Defines | |
| #define | RESIPROCATE_SUBSYSTEM Subsystem::SIP |
Functions | |
| int | logsInCall () |
| int | debugLogsInCall () |
| int | main (int argc, char *argv[]) |
| #define RESIPROCATE_SUBSYSTEM Subsystem::SIP |
Definition at line 14 of file testExternalLogger.cxx.
| int debugLogsInCall | ( | ) |
Definition at line 48 of file testExternalLogger.cxx.
References DebugLog.
Referenced by main().
{
DebugLog(<< "Got here?");
return 17;
}
| int logsInCall | ( | ) |
Definition at line 41 of file testExternalLogger.cxx.
References InfoLog.
Referenced by main().
{
InfoLog(<< "Got here?");
return 17;
}
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 77 of file testExternalLogger.cxx.
References resip::Log::Crit, resip::Log::Debug, DebugLog, debugLogsInCall(), resip::Log::Err, resip::Timer::getTimeMs(), resip::Log::Info, InfoLog, resip::Log::initialize(), resip::ThreadIf::join(), logsInCall(), resip::ThreadIf::run(), resip::Log::setLevel(), resip::Log::setServiceLevel(), resip::ThreadIf::shutdown(), resip::Log::Stack, and resip::Log::Syslog.
{
ExampleExternalLogger exampleExternalLogger;
Log::initialize(Log::Syslog, Log::Info, argv[0], exampleExternalLogger);
DebugLog(<<"This should not appear.");
InfoLog(<<"This should appear.");
LogThread service1a("service1----A", Log::ThreadSetting(1, Log::Debug));
LogThread service1b("service1-------B", Log::ThreadSetting(1, Log::Debug));
LogThread service1c("service1---------C", Log::ThreadSetting(1, Log::Debug));
LogThread service2a("service2-----------A", Log::ThreadSetting(2, Log::Debug));
LogThread service2b("service2------------------B", Log::ThreadSetting(2, Log::Err));
service1a.run();
service1b.run();
service1c.run();
service2a.run();
service2b.run();
#if !defined(WIN32) && !defined(TARGET_OS_MAC)
sleep(2);
InfoLog(<<"Setting service 1 to INFO\n");
Log::setServiceLevel(1, Log::Info);
sleep(2);
InfoLog(<<"Setting service 1 to CRIT\n");
Log::setServiceLevel(1, Log::Crit);
sleep(2);
InfoLog(<<"Setting service 2 to STACK\n");
Log::setServiceLevel(2, Log::Stack);
sleep(2);
InfoLog(<<"Setting service 1 to DEBUG\n");
Log::setServiceLevel(1, Log::Debug);
sleep(2);
#endif
DebugLog(<<"This should still not appear.");
InfoLog(<<"This should still appear.");
service1a.shutdown();
service1b.shutdown();
service1c.shutdown();
service2a.shutdown();
service2b.shutdown();
service1a.join();
service1b.join();
service1c.join();
service2a.join();
service2b.join();
Log::setLevel(Log::Info);
if (false)
{
UInt64 start = Timer::getTimeMs();
for (int i = 0; i < 10000; i++)
{
InfoLog(<< "string");
}
cerr << "Info Took: " << Timer::getTimeMs() - start << endl;
}
if (false)
{
UInt64 start = Timer::getTimeMs();
for (int i = 0; i < 10000; i++)
{
DebugLog(<< "string");
}
cerr << "Debug Took: " << Timer::getTimeMs() - start << endl;
}
InfoLog(<< "Recursive debug: " << debugLogsInCall());
DebugLog(<< "Recursive non-debug OK: " << logsInCall());
InfoLog(<< "Recursive non-debug OK!: " << logsInCall());
return 0;
}

1.7.5.1