本文整理汇总了C++中Appender::getClass方法的典型用法代码示例。如果您正苦于以下问题:C++ Appender::getClass方法的具体用法?C++ Appender::getClass怎么用?C++ Appender::getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Appender
的用法示例。
在下文中一共展示了Appender::getClass方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readLog
bool Logger::readLog(std::string &target) {
bool success = false;
LockGuard lock(m_mutex);
for (size_t i=0; i<m_appenders.size(); ++i) {
Appender *appender = m_appenders[i];
if (appender->getClass()->derivesFrom(MTS_CLASS(StreamAppender))) {
StreamAppender *streamAppender =
static_cast<StreamAppender *>(appender);
if (streamAppender->logsToFile()) {
streamAppender->readLog(target);
success = true;
break;
}
}
}
return success;
}
示例2: mtssrv
//.........这里部分代码省略.........
cout << " the load or creating scheduling-only nodes in conjunction with" << endl;
cout << " the -c and -s parameters, e.g. -p 0 -c host1;host2;host3,..." << endl << endl;
cout << " -q Quiet mode - do not print any log messages to stdout" << endl << endl;
cout << " -c hosts Nesting: connect to additional mtssrv instances over a network." << endl;
cout << " Requires a semicolon-separated list of host names of the form" << endl;
cout << " host.domain[:port] for a direct connection" << endl;
cout << " or" << endl;
cout << " [email protected][:/path] for a SSH connection (where" << endl;
cout << " 'path' denotes the place where Mitsuba is checked" << endl;
cout << " out -- by default, \"~/mitsuba\" is used)" << endl << endl;
cout << " -s file Connect to additional Mitsuba servers specified in a file" << endl;
cout << " with one name per line (same format as in -c)" << endl<< endl;
cout << " -i name IP address / host name on which to listen for connections" << endl << endl;
cout << " -l port Listen for connections on a certain port (Default: " << MTS_DEFAULT_PORT << ")." << endl;
cout << " To listen on stdin, specify \"-ls\" (implies -q)" << endl << endl;
cout << " -n name Assign a node name to this instance (Default: host name)" << endl << endl;
cout << " -v Be more verbose (can be specified twice)" << endl << endl;
cout << " -L level Explicitly specify the log level (trace/debug/info/warn/error)" << endl << endl;
cout << " For documentation, please refer to http://www.mitsuba-renderer.org/docs.html" << endl;
return 0;
}
}
/* Configure the logging subsystem */
ref<Logger> log = Thread::getThread()->getLogger();
log->setLogLevel(logLevel);
/* Initialize OpenMP */
Thread::initializeOpenMP(nprocs);
/* Disable the default appenders */
for (size_t i=0; i<log->getAppenderCount(); ++i) {
Appender *appender = log->getAppender(i);
if (appender->getClass()->derivesFrom(MTS_CLASS(StreamAppender)))
log->removeAppender(appender);
}
log->addAppender(new StreamAppender(formatString("mtssrv.%s.log", nodeName.c_str())));
if (!quietMode)
log->addAppender(new StreamAppender(&std::cout));
SLog(EInfo, "Mitsuba version %s, Copyright (c) " MTS_YEAR " Wenzel Jakob",
Version(MTS_VERSION).toStringComplete().c_str());
#if defined(__WINDOWS__)
/* Custom handler for Ctrl-C signals */
SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
#endif
/* Configure the scheduling subsystem */
Scheduler *scheduler = Scheduler::getInstance();
for (int i=0; i<nprocs; ++i)
scheduler->registerWorker(new LocalWorker(i, formatString("wrk%i", i)));
std::vector<std::string> hosts = tokenize(networkHosts, ";");
/* Establish network connections to nested servers */
for (size_t i=0; i<hosts.size(); ++i) {
const std::string &hostName = hosts[i];
ref<Stream> stream;
if (hostName.find("@") == std::string::npos) {
int port = MTS_DEFAULT_PORT;
std::vector<std::string> tokens = tokenize(hostName, ":");
if (tokens.size() == 0 || tokens.size() > 2) {
SLog(EError, "Invalid host specification '%s'!", hostName.c_str());
} else if (tokens.size() == 2) {
示例3: mitsuba_app
//.........这里部分代码省略.........
case 'b':
blockSize = strtol(optarg, &end_ptr, 10);
if (*end_ptr != '\0')
SLog(EError, "Could not parse the block size!");
if (blockSize < 2 || blockSize > 128)
SLog(EError, "Invalid block size (should be in the range 2-128)");
break;
case 'z':
progressBars = false;
break;
case 'q':
quietMode = true;
break;
case 'h':
default:
help();
return 0;
}
}
ProgressReporter::setEnabled(progressBars);
/* Initialize OpenMP */
Thread::initializeOpenMP(nprocs);
/* Configure the logging subsystem */
ref<Logger> log = Thread::getThread()->getLogger();
log->setLogLevel(logLevel);
log->setErrorLevel(treatWarningsAsErrors ? EWarn : EError);
/* Disable the default appenders */
for (size_t i=0; i<log->getAppenderCount(); ++i) {
Appender *appender = log->getAppender(i);
if (appender->getClass()->derivesFrom(MTS_CLASS(StreamAppender)))
log->removeAppender(appender);
}
log->addAppender(new StreamAppender(formatString("mitsuba.%s.log", nodeName.c_str())));
if (!quietMode)
log->addAppender(new StreamAppender(&std::cout));
SLog(EInfo, "Mitsuba version %s, Copyright (c) " MTS_YEAR " Wenzel Jakob",
Version(MTS_VERSION).toStringComplete().c_str());
/* Configure the scheduling subsystem */
Scheduler *scheduler = Scheduler::getInstance();
bool useCoreAffinity = nprocs == nprocs_avail;
for (int i=0; i<nprocs; ++i)
scheduler->registerWorker(new LocalWorker(useCoreAffinity ? i : -1,
formatString("wrk%i", i)));
std::vector<std::string> hosts = tokenize(networkHosts, ";");
/* Establish network connections to nested servers */
for (size_t i=0; i<hosts.size(); ++i) {
const std::string &hostName = hosts[i];
ref<Stream> stream;
if (hostName.find("@") == std::string::npos) {
int port = MTS_DEFAULT_PORT;
std::vector<std::string> tokens = tokenize(hostName, ":");
if (tokens.size() == 0 || tokens.size() > 2) {
SLog(EError, "Invalid host specification '%s'!", hostName.c_str());
} else if (tokens.size() == 2) {
port = strtol(tokens[1].c_str(), &end_ptr, 10);
if (*end_ptr != '\0')
SLog(EError, "Invalid host specification '%s'!", hostName.c_str());
示例4: mtsutil
int mtsutil(int argc, char **argv) {
char optchar, *end_ptr = NULL;
try {
/* Default settings */
int nprocs = getProcessorCount();
std::string nodeName = getHostName(),
networkHosts = "", destFile="";
bool quietMode = false;
ELogLevel logLevel = EInfo;
FileResolver *fileResolver = Thread::getThread()->getFileResolver();
bool testCaseMode = false;
if (argc < 2) {
help();
return 0;
}
optind = 1;
/* Parse command-line arguments */
while ((optchar = getopt(argc, argv, "+a:c:s:n:p:qhvt")) != -1) {
switch (optchar) {
case 'a': {
std::vector<std::string> paths = tokenize(optarg, ";");
for (unsigned int i=0; i<paths.size(); ++i)
fileResolver->addPath(paths[i]);
}
break;
case 'c':
networkHosts = networkHosts + std::string(";") + std::string(optarg);
break;
case 't':
testCaseMode = true;
break;
case 's': {
std::ifstream is(optarg);
if (is.fail())
SLog(EError, "Could not open host file!");
std::string host;
while (is >> host) {
if (host.length() < 1 || host.c_str()[0] == '#')
continue;
networkHosts = networkHosts + std::string(";") + host;
}
}
break;
case 'n':
nodeName = optarg;
break;
case 'v':
logLevel = EDebug;
break;
case 'p':
nprocs = strtol(optarg, &end_ptr, 10);
if (*end_ptr != '\0')
SLog(EError, "Could not parse the processor count!");
break;
case 'q':
quietMode = true;
break;
case 'h':
default:
help();
return 0;
}
}
/* Configure the logging subsystem */
ref<Logger> log = Thread::getThread()->getLogger();
log->setLogLevel(logLevel);
/* Initialize OpenMP */
Thread::initializeOpenMP(nprocs);
/* Disable the default appenders */
for (size_t i=0; i<log->getAppenderCount(); ++i) {
Appender *appender = log->getAppender(i);
if (appender->getClass()->derivesFrom(MTS_CLASS(StreamAppender)))
log->removeAppender(appender);
}
log->addAppender(new StreamAppender(formatString("mitsuba.%s.log", nodeName.c_str())));
if (!quietMode)
log->addAppender(new StreamAppender(&std::cout));
SLog(EInfo, "Mitsuba version %s, Copyright (c) " MTS_YEAR " Wenzel Jakob",
Version(MTS_VERSION).toStringComplete().c_str());
/* Configure the scheduling subsystem */
Scheduler *scheduler = Scheduler::getInstance();
for (int i=0; i<nprocs; ++i)
scheduler->registerWorker(new LocalWorker(formatString("wrk%i", i)));
std::vector<std::string> hosts = tokenize(networkHosts, ";");
/* Establish network connections to nested servers */
for (size_t i=0; i<hosts.size(); ++i) {
const std::string &hostName = hosts[i];
ref<Stream> stream;
if (hostName.find("@") == std::string::npos) {
//.........这里部分代码省略.........
示例5: main
int main(int argc, char *argv[]) {
int retval;
/* Initialize Xerces-C */
try {
XMLPlatformUtils::Initialize();
} catch(const XMLException &toCatch) {
fprintf(stderr, "Error during Xerces initialization: %s",
XMLString::transcode(toCatch.getMessage()));
return -1;
}
/* Initialize the core framework */
Class::staticInitialization();
PluginManager::staticInitialization();
Statistics::staticInitialization();
Thread::staticInitialization();
Thread::initializeOpenMP(getProcessorCount());
Logger::staticInitialization();
Spectrum::staticInitialization();
Scheduler::staticInitialization();
SHVector::staticInitialization();
#if defined(__LINUX__)
XInitThreads();
#endif
#if defined(__OSX__)
MTS_AUTORELEASE_BEGIN()
/* Required for the mouse relocation in GLWidget */
CGSetLocalEventsSuppressionInterval(0.0f);
MTS_AUTORELEASE_END()
#endif
#ifdef WIN32
/* Initialize WINSOCK2 */
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2,2), &wsaData))
SLog(EError, "Could not initialize WinSock2!");
if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
SLog(EError, "Could not find the required version of winsock.dll!");
#endif
#if !defined(WIN32)
/* Avoid zombies processes when running the server */
struct sigaction sa;
sa.sa_handler = collect_zombies;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART;
if (sigaction(SIGCHLD, &sa, NULL) == -1)
SLog(EWarn, "Error in sigaction(): %s!", strerror(errno));
#endif
qRegisterMetaType<ELogLevel>("ELogLevel");
qRegisterMetaType<fs::path>("fs::path");
MitsubaApplication app(argc, argv);
try {
QFile stylesheet(":/resources/stylesheet.css");
if (!stylesheet.open(QFile::ReadOnly)) {
QMessageBox::critical(NULL, "Internal error", "Could not open stylesheet!");
exit(-1);
}
app.setStyleSheet(QTextStream(&stylesheet).readAll().toAscii());
#if defined(__OSX__)
app.setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
/* Disable the default appenders */
ref<Logger> logger = Thread::getThread()->getLogger();
for (size_t i=0; i<logger->getAppenderCount(); ++i) {
Appender *appender = logger->getAppender(i);
if (appender->getClass()->derivesFrom(MTS_CLASS(StreamAppender)))
logger->removeAppender(appender);
}
#if defined(__OSX__)
/* Create a log file inside the application bundle */
MTS_AUTORELEASE_BEGIN()
logger->addAppender(new StreamAppender(formatString("%s/mitsuba.%s.log",
__ubi_bundlepath().c_str(), getHostName().c_str())));
MTS_AUTORELEASE_END()
#else
/* Create a log file inside the current working directory */
logger->addAppender(new StreamAppender(formatString("mitsuba.%s.log", getHostName().c_str())));
#endif
#if !defined(WIN32)
/* Correct number parsing on some locales (e.g. ru_RU) */
setlocale(LC_NUMERIC, "C");
#endif
mainWindow = new MainWindow();
mainWindow->initWorkers();
retval = app.exec();
delete mainWindow;
} catch (const std::exception &e) {
SLog(EWarn, "Critical exception during startup: %s", e.what());
//.........这里部分代码省略.........