SYSLOG

Section: Linux Programmer's Manual (2)
Updated: 11 June 1995
Index
Return to Main Contents
 

이름

syslog - 커널 메시지 링 버퍼를 읽거나 소거한다; console_loglevel을 설정한다.  

사용법

#include <unistd.h>

#include <linux/unistd.h>

_syscall3(int, syslog, int, type, char *, bufp, int, len);

int syslog(int type, char *bufp, int len);
 

설명

이것은 아마도 당신이 흥미를 가질만한 기능은 아니다. C라이브러리 인터페이스를 위해 syslog(3) 를 본다. 이 페이지는 단지 텅빈 커널 시스템 호출 인터페이스를 문서화했다. type인수는 syslog 에 의한 실행을 결정한다. kernel/printk.c 로부터 인용:
/*
 * Commands to sys_syslog:
 *
 *      0 -- Close the log.  Currently a NOP.
 *      1 -- Open the log. Currently a NOP.
 *      2 -- Read from the log.
 *      3 -- Read up to the last 4k of messages in the ring buffer.
 *      4 -- Read and clear last 4k of messages in the ring buffer
 *      5 -- Clear ring buffer.
 *      6 -- Disable printk's to console
 *      7 -- Enable printk's to console
 *      8 -- Set level of messages printed to console
 */
기능 3은 비root 프로세스만을 허용한다. 커널 로그 버퍼
커널은 메시지가 커널함수 printk()/fh 인수로써 주어지는것이 저장된 LOG_BUF_LEN (4096, since 1.3.54: 8192, since 2.1.113: 16384)의 순환버퍼를 갖는다. 호출 syslog (2,buf,len) 는 이 커널 로그 버퍼가 비워지지 않을때 까지 대기한 후 대부분의 len바이트에서 버퍼 buf를 읽는다. 그것은 읽어들인 바이트 양을 반환한다. 로그에서 읽은 바이트는 로그버퍼로부터 사라진다: 정보는 한번만 읽을 수 있다. 이것은 사용자 프로그램이 /proc/kmsg 를 읽을때 커널에 의해 실행된 함수이다. 호출 syslog (3,buf,len) 는 로그버퍼로부터 마지막 len 바이트를 읽지만, 버퍼에 기록된 이상은 읽지는 못할 것이다. 호출 syslog (4,buf,len) 도 같다. 호출 syslog (5,dummy,idummy) 는 단지 'clear ring buffer' 명령을 실행한다. 메세지의 모든 텍스트행은 로그레벨이 있다. 이 레벨은 d가 1-7범위안의 <d>를 가진 시작행이 아니라면 DEFAULT_MESSAGE_LOGLEVEL - 1 (6)이다. 로그레벨의 전통적의미는 다음과 같이 <linux/kernel.h> 에 정의되어 있다:
#define KERN_EMERG    "<0>"  /* system is unusable               */
#define KERN_ALERT    "<1>"  /* action must be taken immediately */
#define KERN_CRIT     "<2>"  /* critical conditions              */
#define KERN_ERR      "<3>"  /* error conditions                 */
#define KERN_WARNING  "<4>"  /* warning conditions               */
#define KERN_NOTICE   "<5>"  /* normal but significant condition */
#define KERN_INFO     "<6>"  /* informational                    */
#define KERN_DEBUG    "<7>"  /* debug-level messages             */
 

반환값

에러시, -1이 반환되고, errno가 설정된다. 그렇지 않으면 2,3,4와 같은 형태를 위해 syslog()는 읽은 바이트 수를 반환하고, 그렇지 않으면 0이다.  

에러

EPERM
시도는 console_loglevel을 바꾸거나 root권한이 없는 프로세스에 의해 커널 메세지 링 버퍼를 소거한다.
EINVAL
잘못된 배개변수.
ERESTARTSYS
시스템 호출은 아무것도 읽지 못하는 시그널에 의해 중단된다.
 

호환

이 시스템 호출은 리눅스에 특화되었다. 그리고 다른 프로그램에서는 쓰여지지 않는다.  

관련 항목

syslog(3)


 

Index

이름
사용법
설명
반환값
에러
호환
관련 항목

This document was created by man2html, using the manual pages.
Time: 08:07:00 GMT, March 25, 2004