本文整理汇总了C++中Log::LogToSyslog方法的典型用法代码示例。如果您正苦于以下问题:C++ Log::LogToSyslog方法的具体用法?C++ Log::LogToSyslog怎么用?C++ Log::LogToSyslog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::LogToSyslog方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bfddMain
static int bfddMain(int argc, char *argv[])
{
int argIndex;
SockAddr connectAddr;
const char *valueString;
//gLog.LogToFile("/tmp/bfd.log");
UtilsInit();
gLog.LogToSyslog("bfdd-control", false);
gLog.Optional(Log::App, "Startup %x", getpid());
//Parse command line options
for (argIndex = 1; argIndex < argc; argIndex++)
{
if (0 == strcmp("--altport", argv[argIndex]))
{
if (connectAddr.IsValid())
{
fprintf(stderr, "Only a single --altport or --control option is allowed.\n");
exit(1);
}
// Backwards compatability only ... use --control
connectAddr.FromString("127.0.0.1", ALT_PORTNUM);
}
else if (CheckArg("--control", argv[argIndex], &valueString))
{
if (!valueString || *valueString == '\0')
{
fprintf(stderr, "--control must be followed by an '=' and a ip address with a port.\n");
exit(1);
}
if (!connectAddr.FromString(valueString))
{
fprintf(stderr, "--control address <%s> is not an IPv4 or IPv6 address.\n", valueString);
exit(1);
}
if (!connectAddr.HasPort())
{
fprintf(stderr, "--control address must have a port specified. The address <%s> does not conatin a port.\n", valueString);
exit(1);
}
}
else if (0 == strncmp("--", argv[argIndex], 2))
{
fprintf(stderr, "Unrecognized %s command line option %s.\n", ControlAppName, argv[argIndex]);
exit(1);
}
else
break;
}
if (argIndex >= argc)
{
fprintf(stderr, "No command. Try \"man %s\" for a list of commands.\n", ControlAppName);
exit(1);
}
// "version" is special because we tell first. Than lest the beacon handle it.
if (0 == strcmp(argv[argIndex], "version"))
{
fprintf(stdout, "%s v%s\n", ControlAppName, SofwareVesrion);
}
if (!connectAddr.IsValid())
connectAddr.FromString("127.0.0.1", PORTNUM);
// "load" is special because we send a series of commands..
if (0 == strcmp(argv[argIndex], "load"))
{
argIndex++;
if (argIndex >= argc)
{
fprintf(stderr, "Must supply a script file after 'load'\n");
exit(1);
}
fprintf(stdout, "Running script from file <%s>\n", argv[argIndex]);
if (!doLoadScript(argv[argIndex], connectAddr))
{
fprintf(stderr, "Script load failed.\n");
exit(1);
}
fprintf(stdout, "Completed script from file <%s>\n", argv[argIndex]);
exit(0);
}
// To allow for quotes, we concatenate all the arguments, separating them with
// "NULL".
vector<char> buffer;
buffer.reserve(MaxCommandSize);
for (; argIndex < argc; argIndex++)
{
AddParamToBuffer(buffer, argv[argIndex]);
}
//.........这里部分代码省略.........