• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ LOG_MASK函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LOG_MASK函数的典型用法代码示例。如果您正苦于以下问题:C++ LOG_MASK函数的具体用法?C++ LOG_MASK怎么用?C++ LOG_MASK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LOG_MASK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:wuwx,项目名称:simba,代码行数:35,代码来源:main.c


示例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);
}
开发者ID:kenzaburo,项目名称:OpenSaf-FrameWork,代码行数:16,代码来源:logtrace.c


示例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);
}
开发者ID:ifzz,项目名称:evm,代码行数:28,代码来源:hello4_evm.c


示例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;
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:34,代码来源:Log_Msg_UNIX_Syslog.cpp


示例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;
}
开发者ID:rmlawton,项目名称:LDM,代码行数:52,代码来源:noaaportIngester.c


示例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();
}
开发者ID:IoTone,项目名称:ccnx-ldplib,代码行数:29,代码来源:ldp_c_units.cpp


示例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;
}
开发者ID:jamjr,项目名称:Helios-NG,代码行数:34,代码来源:syslog.c


示例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) );
}
开发者ID:zhaozg,项目名称:openscep,代码行数:38,代码来源:syslog-client.c


示例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
}
开发者ID:KobaltRo,项目名称:dleyna-core-1,代码行数:32,代码来源:log.c


示例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);
}
开发者ID:gmoonen,项目名称:craftd,代码行数:34,代码来源:ConsoleLogger.c


示例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);
	}
}
开发者ID:cguiraud,项目名称:media-service-upnp,代码行数:27,代码来源:log.c


示例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);
}
开发者ID:chenyifu,项目名称:asp_tinet_mb,代码行数:48,代码来源:syslog.c


示例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);
}
开发者ID:asapfurb,项目名称:emscripten,代码行数:10,代码来源:syslog.c


示例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);
}
开发者ID:Charlian,项目名称:python-cobra,代码行数:10,代码来源:syslogmodule.c


示例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;
}
开发者ID:kodybrown,项目名称:haiku,代码行数:42,代码来源:SyslogTest.cpp


示例16: lc_syslog_setmask

int lc_syslog_setmask(lua_State* L) {
    int level_idx = luaL_checkoption(L, 1, "notice", level_strings);
    int mask = 0;

    do {
        mask |= LOG_MASK(level_constants[level_idx]);
    } while(++level_idx <= 4);

    setlogmask(mask);
    return 0;
}
开发者ID:hjbolide,项目名称:prosody,代码行数:11,代码来源:pposix.c


示例17: async_vsyslog

void async_vsyslog(struct async_syslog_state* state, int priority, const char *format, va_list ap) {
	if (!(state->mask & LOG_MASK(LOG_PRI(priority))) || (priority &~ (LOG_PRIMASK|LOG_FACMASK)))
		return;

	if (state->buffer_get == state->buffer_put && !state->buffers_empty)
		return;

	connect_to_syslog(state);
	add_to_log_buffer(state, priority, format, ap);
	write_to_syslog(state);
}
开发者ID:cyclefusion,项目名称:szarp,代码行数:11,代码来源:async_syslog.c


示例18: Psetlogmask

static int Psetlogmask(lua_State* L) 		/** setlogmask(priority...) */
{
	int argno = lua_gettop(L);
	int mask = 0;
	int i;

	for (i=1; i <= argno; i++)
		mask |= LOG_MASK(luaL_checkint(L,i));

	return pushresult(L, setlogmask(mask),"setlogmask");
}
开发者ID:Sciumo,项目名称:luaposix,代码行数:11,代码来源:lposix.c


示例19: main

/* There are three ways to generate log messages:
 * 1. Kernel routines can call the log() function. These messages can be
 * read by any user process that openS and readS the /dev/klog device.
 * 2. Most user processes (daemons) call the syslog() function to generate
 * log messages. This causes the message to be sent to the UNIX domain
 * datagram socket /dev/log.
 * 3. A user process on this host, or on some other host that is connected
 * to this host by a TCP/IP network, can send log messages to UDP port 514.
 * Note that the syslog() function never generates these UDP datagrams:
 * they require explicit network programming by the process generating the
 * log message.
 * 这三种方式最终将数据传给syslogd守护进程,由syslogd来负责将数据写入文件,
 * 或者显示到控制台,或者再传给其他的主机(host).
 * #include <syslog.h>
 * void openlog(const char *ident, int option, int facility);
 * void syslog(int priority, const char *format, ...);
 * void closelog(void);
 * Calling openlog() is optional. If it's not called, the first time syslog
 * is called, openlog() is called automatically. Calling closelog() is also
 * optional--it just closes the descriptor that was being used to
 * communicate with the syslogd daemon.
 * openlog()函数的第一个参数可以指定一个嵌入到每条log开头的字符串.如果没有
 * 调用openlog()函数就直接调用syslog(),则syslog()默认会用所执行的命令名来
 * 嵌入到每条log开头,这一点是实际测试发现的,书中和man手册都没有提到这个规则
 * 关于 option, facility, priority 参数的具体取值要看一下man手册.
 *
 * int setlogmask(int mask);
 *              Returns: previous log priority mask value.
 * A process has a log priority mask that determines which calls to syslog
 * may be logged. All other calls will be ignored. Logging is enabled for
 * the priorities that have the corresponding bit set in mask. The initial
 * mask is such that logging is enabled for all priorities. If the mask
 * argument is 0, the current logmask is not modified.
 * The eight priorities are LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR,
 * LOG_WARNING, LOG_NOTIE, LOG_INFO, and LOG_DEBUG. The bit corresponding to
 * a priority p is LOG_MASK(p).
 *
 * In addition to syslog(), many platforms provide a variant that handles
 * variable argument lists.
 * #include <syslog.h>
 * #include <stdarg.h>
 * void vsyslog(int priority, const char *format, va_list arg);
 */
int main(void)
{
    /* 这里虽然指定了log的优先级,但是查看/var/log/user.log文件,里面没有体现
     * 出来这些优先级,也就是log里面没有字段来表示log的优先级.
     */
    syslog(LOG_ERR, "zhong cheng juan shu");

    /* 调用openlog()指定log前缀为 "TIAN" */
    openlog("TIAN", LOG_CONS | LOG_PID, LOG_USER);
    syslog(LOG_ALERT, "tian xia you qing ren");

    /* 上面调用openlog()指定了LOG_PID选项,当时觉得下面调用closelog()后,这个
     * LOG_PID选项应该会失效,但是实际执行结果不是这样,后面的log语句也带上了
     * 进程ID,所以执行closelog()后,LOG_PID选项还是生效的.但奇怪的是,"TIAN"
     * 前缀却失效了,后面的log语句没有带有这个"TIAN"前缀.如果删掉closelog()
     * 语句,后面的log语句的确是带有"TIAN"前缀的,可能是因为LOG_PID选项是
     * openlog()函数独有的,所以closelog()函数不会让LOG_PID选项失效吧.
     */
    closelog();

    /* 要调用LOG_MASK()来将log优先级转换为对应的log mask.直接写为
     * setlogmask(LOG_ERR); 不会得到预期的结果.
     */
    setlogmask(LOG_MASK(LOG_ERR));

    /* 上面将log mask设置为了LOG_ERR,则下面LOG_CRIT优先级的log将不会被
     * 写入到log文件,且这句log会被忽略.即使后面将log mask设置为LOG_CRIT,
     * 这句log也不会被写入到log文件中.
     */
    syslog(LOG_CRIT, "how are you");

    /* LOG_ERR优先级的log能够写入到log文件 */
    syslog(LOG_ERR, "fine....");

    /* 将log mask设置为 LOG_CRIT后,下面的LOG_CRIT优先级log就能写入到log文件
     */
    setlogmask(LOG_MASK(LOG_CRIT));
    syslog(LOG_CRIT, "how are you again");

    return 0;
}
开发者ID:forkhope,项目名称:apue2,代码行数:84,代码来源:syslog.c


示例20: main

int main(int argc, char **argv)
{
    openlog("ntpc", LOG_PID, LOG_USER);
    if (!nvram_contains_word("log_events", "ntp")) {
        setlogmask(LOG_MASK(LOG_EMERG));	// can't set to 0
    }

    if (strstr(argv[0], "ntpsync") != NULL) return ntpsync_main(argc, argv);
    if (strstr(argv[0], "ntpstep") != NULL) return ntpstep_main(argc, argv);

    return ntpc_main(argc, argv);
}
开发者ID:Stan-Lin,项目名称:tomatoraf,代码行数:12,代码来源:ntpc.c



注:本文中的LOG_MASK函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LOG_MESSAGE函数代码示例发布时间:2022-05-30
下一篇:
C++ LOG_L函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap