本文整理汇总了C++中LOG_MASK函数的典型用法代码示例。如果您正苦于以下问题:C++ LOG_MASK函数的具体用法?C++ LOG_MASK怎么用?C++ LOG_MASK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOG_MASK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_log_mask
int test_log_mask(struct harness_t *harness_p)
{
struct log_object_t foo;
/* Initialize the log objects. */
BTASSERT(log_object_init(&foo,
"foo",
LOG_UPTO(INFO)) == 0);
BTASSERT(log_object_get_log_mask(&foo) == 0x0f);
/* Log all. */
BTASSERT(log_object_set_log_mask(&foo, LOG_ALL) == 0);
BTASSERT(log_object_get_log_mask(&foo) == 0x1f);
/* Log none. */
BTASSERT(log_object_set_log_mask(&foo, LOG_NONE) == 0);
BTASSERT(log_object_get_log_mask(&foo) == 0x00);
/* Log error. */
BTASSERT(log_object_set_log_mask(&foo, LOG_MASK(ERROR)) == 0);
BTASSERT(log_object_get_log_mask(&foo) == 0x02);
/* Invalid levels are discarded. */
BTASSERT(log_object_set_log_mask(&foo, 0xf0) == 0);
BTASSERT(log_object_get_log_mask(&foo) == 0x10);
/* Is enabled for. */
BTASSERT(log_object_set_log_mask(&foo, LOG_MASK(ERROR)) == 0);
BTASSERT(log_object_is_enabled_for(&foo, LOG_INFO) == 0);
BTASSERT(log_object_is_enabled_for(&foo, LOG_ERROR) == 1);
thrd_set_log_mask(thrd_self(), 0x00);
BTASSERT(log_object_is_enabled_for(NULL, LOG_ERROR) == 0);
return (0);
}
示例2: sighup_handler
/**
* HUP signal handler to toggle info log level on/off
* @param sig
*/
static void sighup_handler(int sig)
{
if ((logmask & LOG_MASK(LOG_INFO)) & LOG_MASK(LOG_INFO)) {
logmask = LOG_UPTO(LOG_NOTICE);
syslog(LOG_NOTICE, "logtrace: info level disabled");
} else {
logmask = LOG_UPTO(LOG_INFO);
syslog(LOG_NOTICE, "logtrace: info level enabled");
}
setlogmask(logmask);
}
示例3: main
int main(int argc, char *argv[])
{
evm_init_struct *evm_init_ptr;
usage_check(argc, argv);
log_mask = LOG_MASK(LOG_EMERG) | LOG_MASK(LOG_ALERT) | LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ERR);
/* Setup LOG_MASK according to startup arguments! */
if (evmlog_normal) {
log_mask |= LOG_MASK(LOG_WARNING);
log_mask |= LOG_MASK(LOG_NOTICE);
}
if ((evmlog_verbose) || (evmlog_trace))
log_mask |= LOG_MASK(LOG_INFO);
if (evmlog_debug)
log_mask |= LOG_MASK(LOG_DEBUG);
setlogmask(log_mask);
if ((evm_init_ptr = hello4_evm_init(1)) == NULL)
exit(EXIT_FAILURE);
if (hello4_evm_run(evm_init_ptr) < 0)
exit(EXIT_FAILURE);
exit(EXIT_SUCCESS);
}
示例4: ACE_BIT_ENABLED
int
ACE_Log_Msg_UNIX_Syslog::convert_log_mask (int lm_mask)
{
int syslog_mask = 0;
if (ACE_BIT_ENABLED (lm_mask, LM_TRACE)
|| ACE_BIT_ENABLED (lm_mask, LM_DEBUG))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_DEBUG));
if (ACE_BIT_ENABLED (lm_mask, LM_STARTUP)
|| ACE_BIT_ENABLED (lm_mask, LM_SHUTDOWN)
|| ACE_BIT_ENABLED (lm_mask, LM_INFO))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_INFO));
if (ACE_BIT_ENABLED (lm_mask, LM_NOTICE))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_NOTICE));
if (ACE_BIT_ENABLED (lm_mask, LM_ERROR))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ERR));
if (ACE_BIT_ENABLED (lm_mask, LM_WARNING))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_WARNING));
if (ACE_BIT_ENABLED (lm_mask, LM_CRITICAL))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_CRIT));
if (ACE_BIT_ENABLED (lm_mask, LM_ALERT))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ALERT));
if (ACE_BIT_ENABLED (lm_mask, LM_EMERGENCY))
ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_EMERG));
return syslog_mask;
}
示例5: signal_handler
/*
* Handles a signal.
*/
static void signal_handler(
const int sig) /**< [in] Signal to be handled */
{
#ifdef SVR3SIGNALS
/*
* Some systems reset handler to SIG_DFL upon entry to handler.
* In that case, we reregister our handler.
*/
(void)signal(sig, signal_handler);
#endif
switch (sig) {
case SIGINT:
exit(1);
case SIGTERM:
(void)pthread_cancel(readerThread);
break;
case SIGUSR1:
if (NULL != reader) {
(void)pthread_mutex_lock(&mutex);
reportStatistics = 1;
(void)pthread_cond_signal(&cond);
(void)pthread_mutex_unlock(&mutex);
}
break;
case SIGUSR2: {
unsigned logMask = getulogmask();
if ((logMask & LOG_MASK(LOG_WARNING)) == 0) {
(void)setulogmask(LOG_UPTO(LOG_WARNING));
}
else if ((logMask & LOG_MASK(LOG_NOTICE)) == 0) {
(void)setulogmask(LOG_UPTO(LOG_NOTICE));
}
else if ((logMask & LOG_MASK(LOG_INFO)) == 0) {
(void)setulogmask(LOG_UPTO(LOG_INFO));
}
else if ((logMask & LOG_MASK(LOG_DEBUG)) == 0) {
(void)setulogmask(LOG_UPTO(LOG_DEBUG));
}
else {
(void)setulogmask(LOG_UPTO(LOG_ERR));
}
break;
}
}
return;
}
示例6: TEST
TEST(LDPCUnitTest, GetPeerMetadata) {
TLDPSettings *ldp_settings_obj = NULL;
char *metadata = NULL;
size_t bytes_read = 0;
LDPLOG = &ldp_log_console;
LDPLOG_setmask = &ldp_log_console_setlogmask;
LDPLOG_setmask(LOG_MASK(LOG_ERR));
openlog ("LDPCUnitTest", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); // This should use stdout, not syslog messages file
ldp_settings_obj = ldp_settings_create();
EXPECT_TRUE(ldp_settings_obj);
EXPECT_TRUE(ldp_settings_init(ldp_settings_obj) == 0);
LDPLOG(LOG_DEBUG, "about to call ldp_get_peer_metadata_as_bytes(%s)", "86753099");
metadata = ldp_get_peer_metadata_as_bytes("86753099", &bytes_read, NULL);
LDPLOG(LOG_DEBUG, "done with call to ldp_get_peer_metadata_as_bytes()");
EXPECT_TRUE(metadata != NULL);
if (metadata != NULL) {
LDPLOG(LOG_DEBUG, "read metadata = %s", metadata);
}
EXPECT_TRUE(bytes_read > 0);
LDPLOG(LOG_DEBUG, "Read = %d", bytes_read);
ldp_settings_destroy(&ldp_settings_obj);
EXPECT_EQ(NULL, ldp_settings_obj);
closelog();
}
示例7: syslog
extern int syslog(int priority, char *message, ... )
{
va_list a;
int n = 0;
int pos = 0;
if( !(logmask & LOG_MASK(priority)) ) return 0;
if( logfd == -1 ) openlog(NULL,LOG_NDELAY,0);
va_start(a,message);
if( logident ) pos += sprintf(logbuf,"SYSLOG: %s ",logident);
else pos += sprintf(logbuf,"SYSLOG: ");
for(;;)
{
char ch = *message++;
if( ch == 0 || (ch == '%' && *message == 'm'))
{
fbuf[n] = 0;
pos += vsprintf(logbuf+pos,fbuf,a);
if( ch == 0 ) break;
message++;
pos += vsprintf(logbuf+pos,sys_errlist[errno],a);
n = 0;
}
else if( n < 99 ) fbuf[n++] = ch;
}
n = strlen(logbuf);
if( logbuf[n-1] != '\n' ) logbuf[n++] = '\r',logbuf[n++] = '\n';
write(logfd,logbuf,n);
return 0;
}
示例8: vsyslog
/******************************************************************************
* vsyslog
*
* Generate a log message using FMT and using arguments pointed to by AP.
*/
void vsyslog( int pri, char* fmt, va_list ap )
{
static char *month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
SYSTEMTIME stm;
int len;
char *p;
if( !(LOG_MASK( LOG_PRI( pri )) & log_mask) )
return;
openlog( NULL, 0, pri & LOG_FACMASK );
if( !initialized )
return;
if( !(pri & LOG_FACMASK) )
pri |= syslog_facility;
GetLocalTime( &stm );
len = sprintf( datagramm, "<%d>%s %2d %02d:%02d:%02d %s %s%s: ",
pri,
month[ stm.wMonth - 1 ], stm.wDay, stm.wHour, stm.wMinute, stm.wSecond,
local_hostname, syslog_ident? syslog_ident : "", str_pid );
vsnprintf( datagramm + len, datagramm_size - len, fmt, ap );
p = strchr( datagramm, '\n' );
if( p )
*p = 0;
p = strchr( datagramm, '\r' );
if( p )
*p = 0;
sendto( sock, datagramm, strlen(datagramm), 0, (SOCKADDR*) &sa_logger, sizeof(SOCKADDR_IN) );
}
示例9: dleyna_log_init
void dleyna_log_init(const char *program, const char *version)
{
int option = LOG_NDELAY | LOG_PID;
int old;
#ifdef DLEYNA_DEBUG_ENABLED
option |= LOG_PERROR | LOG_CONS;
#endif
memset(&s_log_context, 0, sizeof(s_log_context));
s_log_context.log_domain = g_strdup(program);
prv_set_flags_from_param();
openlog(basename(program), option, LOG_DAEMON);
old = setlogmask(LOG_MASK(LOG_INFO));
syslog(LOG_INFO, "dLeyna core version %s", VERSION);
syslog(LOG_INFO, "%s version %s", program, version);
(void) setlogmask(s_log_context.mask);
s_log_context.old_mask = old;
s_log_context.old_handler = g_log_set_default_handler(
prv_handler,
&s_log_context);
#if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_INFO
if (s_log_context.log_type != DLEYNA_LOG_TYPE_SYSLOG) {
DLEYNA_LOG_INFO("dLeyna core version %s", VERSION);
DLEYNA_LOG_INFO("%s version %s", program, version);
}
#endif
}
示例10: cd_ConsoleLog
static
void
cd_ConsoleLog (int priority, const char* format, ...)
{
/* Return on MASKed log priorities */
if (LOG_MASK(priority) & cd_mask) {
return;
}
static const char* names[] = {
"EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG"
};
va_list ap;
va_start(ap, format);
CDString* priorityBuffer;
CDString* messageBuffer = CD_CreateStringFromFormatList(format, ap);
if (priority >= (sizeof(names) / sizeof(char*)) || priority < 0) {
priorityBuffer = CD_CreateStringFromCString("UNKNOWN");
}
else {
priorityBuffer = CD_CreateStringFromCString(names[priority]);
}
printf("%s: %s\n", CD_StringContent(priorityBuffer), CD_StringContent(messageBuffer));
fflush(stdout);
CD_DestroyString(priorityBuffer);
CD_DestroyString(messageBuffer);
va_end(ap);
}
示例11: msu_log_init
void msu_log_init(const char *program)
{
int option = LOG_NDELAY | LOG_PID;
int old;
#ifdef MSU_DEBUG_ENABLED
option |= LOG_PERROR | LOG_CONS;
#endif
memset(&s_log_context, 0, sizeof(s_log_context));
prv_msu_log_set_flags_from_param();
openlog(basename(program), option, LOG_DAEMON);
old = setlogmask(LOG_MASK(LOG_INFO));
syslog(LOG_INFO, "Media Service UPnP version %s", VERSION);
(void) setlogmask(s_log_context.mask);
s_log_context.old_mask = old;
s_log_context.old_handler = g_log_set_default_handler(
prv_msu_log_handler,
&s_log_context);
if (s_log_context.log_type != MSU_LOG_TYPE_SYSLOG) {
MSU_LOG_INFO("Media Service UPnP version %s", VERSION);
}
}
示例12: syslog_wri_log
/*
* ログ情報の出力
*
* CPUロック状態や実行コンテキストによらず動作できるように実装してある.
*/
ER
syslog_wri_log(uint_t prio, const SYSLOG *p_syslog)
{
SIL_PRE_LOC;
LOG_SYSLOG_WRI_LOG_ENTER(prio, p_syslog);
SIL_LOC_INT();
/*
* ログ時刻の設定
*/
((SYSLOG *) p_syslog)->logtim = _kernel_current_time;
/*
* ログバッファに記録
*/
if ((syslog_logmask & LOG_MASK(prio)) != 0U) {
syslog_buffer[syslog_tail] = *p_syslog;
syslog_tail++;
if (syslog_tail >= TCNT_SYSLOG_BUFFER) {
syslog_tail = 0U;
}
if (syslog_count < TCNT_SYSLOG_BUFFER) {
syslog_count++;
}
else {
syslog_head = syslog_tail;
syslog_lost++;
}
}
/*
* 低レベル出力
*/
if (((~syslog_lowmask_not) & LOG_MASK(prio)) != 0U) {
syslog_print(p_syslog, target_fput_log);
target_fput_log('\n');
}
SIL_UNL_INT();
LOG_SYSLOG_WRI_LOG_LEAVE(E_OK);
return(E_OK);
}
示例13: __vsyslog
void __vsyslog(int priority, const char *message, va_list ap)
{
int cs;
if (!(log_mask & LOG_MASK(priority&7)) || (priority&~0x3ff)) return;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
LOCK(lock);
_vsyslog(priority, message, ap);
UNLOCK(lock);
pthread_setcancelstate(cs, 0);
}
示例14: syslog_log_mask
static PyObject *
syslog_log_mask(PyObject *self, PyObject *args)
{
long mask;
long pri;
if (!PyArg_ParseTuple(args, "l:LOG_MASK", &pri))
return NULL;
mask = LOG_MASK(pri);
return PyInt_FromLong(mask);
}
示例15: main
int
main(int argc, char **argv)
{
openlog_team("SyslogTest", LOG_PID, LOG_USER);
log_team(LOG_ERR, "this is %.", "a test");
int mask = setlogmask_team(LOG_MASK(LOG_CRIT));
printf("team mask == %d\n", mask);
log_team(LOG_WARNING, "this is a warning (hidden)");
log_team(LOG_CRIT, "this is a critical condition (visible)");
setlogmask_team(mask);
syslog(LOG_WARNING, "thread warning (visible)");
syslog(LOG_CRIT, "thread critical condition (visible)");
syslog(LOG_CRIT, "thread critical condition (visible)");
setlogmask(LOG_MASK(LOG_WARNING));
log_team(LOG_WARNING | LOG_MAIL, "2. this is a warning from the MAIL facility (visible)");
log_team(LOG_CRIT, "2. this is a critical condition (visible)");
log_team(LOG_CRIT, "2. this is a critical condition (visible)");
log_team(LOG_CRIT, "2. this is a critical condition (visible)");
// test repeat message suppressing as well
openlog(NULL, LOG_PERROR, LOG_USER);
syslog(LOG_WARNING, "thread/perror warning (visible in stderr as well)");
syslog(LOG_CRIT, "thread/perror critical condition (hidden)");
openlog(NULL, LOG_CONS | LOG_PID, LOG_DAEMON);
syslog(LOG_WARNING, "thread/cons warning (visible in stderr only when there is no syslog_daemon)");
openlog("", 0, LOG_DAEMON);
syslog(LOG_WARNING, "thread warning without ident (visible)");
setlogmask(LOG_EMERG);
closelog();
// this should inherit the team log context on next logging entry
syslog(LOG_ALERT, "now what are we doing here? (visible)");
return 0;
}