Penguin
Annotated edit history of syslog(2) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 SYSLOG
2 !!!SYSLOG
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 RETURN VALUE
7 ERRORS
8 CONFORMING TO
9 SEE ALSO
10 ----
11 !!NAME
12
13
14 syslog - read and/or clear kernel message ring buffer; set console_loglevel
15 !!SYNOPSIS
16
17
18 __#include
19 __ ''type''__, char *__''bufp''__, int__ ''len''__);
20 __
21 !!DESCRIPTION
22
23
24 This is probably not the function you are interested in.
25 Look at syslog(3) for the C library interface. This
26 page only documents the bare kernel system call
27 interface.
28
29
30 The ''type'' argument determines the action taken by
31 __syslog__.
32
33
34 Quoting from ''kernel/printk.c'':
35
36
37 /*
38 * Commands to sys_syslog:
39 *
40 * 0 -- Close the log. Currently a NOP.
41 * 1 -- Open the log. Currently a NOP.
42 * 2 -- Read from the log.
43 * 3 -- Read up to the last 4k of messages in the ring buffer.
44 * 4 -- Read and clear last 4k of messages in the ring buffer
45 * 5 -- Clear ring buffer.
46 * 6 -- Disable printk's to console
47 * 7 -- Enable printk's to console
48 * 8 -- Set level of messages printed to console
49 */
50 Only function 3 is allowed to non-root processes.
51
52
53 __The kernel log buffer__
54 The kernel has a cyclic buffer of length LOG_BUF_LEN (4096,
55 since 1.3.54: 8192, since 2.1.113: 16384) in which messages
56 given as argument to the kernel function ''printk''() are
57 stored (regardless of their loglevel).
58
59
60 The call __syslog__ (2,''buf'',''len'') waits until
61 this kernel log buffer is nonempty, and then reads at most
62 ''len'' bytes into the buffer ''buf''. It returns the
63 number of bytes read. Bytes read from the log disappear from
64 the log buffer: the information can only be read once. This
65 is the function executed by the kernel when a user program
66 reads ''/proc/kmsg''.
67
68
69 The call __syslog__ (3,''buf'',''len'') will read
70 the last ''len'' bytes from the log buffer
71 (nondestructively), but will not read more than was written
72 into the buffer since the last `clear ring buffer' command
73 (which does not clear the buffer at all). It returns the
74 number of bytes read.
75
76
77 The call __syslog__ (4,''buf'',''len'') does
78 precisely the same, but also executes the `clear ring
79 buffer' command.
80
81
82 The call __syslog__ (5,''dummy'',''idummy'') only
83 executes the `clear ring buffer' command.
84
85
86 __The loglevel__
87 The kernel routine ''printk''() will only print a message
88 on the console, if it has a loglevel less than the value of
89 the variable ''console_loglevel'' (initially
90 DEFAULT_CONSOLE_LOGLEVEL (7), but set to 10 if the kernel
91 commandline contains the word `debug', and to 15 in case of
92 a kernel fault - the 10 and 15 are just silly, and
93 equivalent to 8). This variable is set (to a value in the
94 range 1-8) by the call __syslog__
95 (8,''dummy'',''value''). The calls __syslog__
96 (''type'',''dummy'',''idummy'') with ''type''
97 equal to 6 or 7, set it to 1 (kernel panics only) or 7 (all
98 except debugging messages), respectively.
99
100
101 Every text line in a message has its own loglevel. This
102 level is DEFAULT_MESSAGE_LOGLEVEL - 1 (6) unless the line
103 starts with d'' is a digit in the range
104 1-7, in which case the level is ''d''. The conventional
105 meaning of the loglevel is defined in
106 '''' as follows:
107
108
109 #define KERN_EMERG
110 !!RETURN VALUE
111
112
113 In case of error, -1 is returned, and ''errno'' is set.
114 Otherwise, for ''type'' equal to 2, 3 or 4,
115 __syslog__() returns the number of bytes read, and
116 otherwise 0.
117 !!ERRORS
118
119
120 __EPERM__
121
122
123 An attempt was made to change console_loglevel or clear the
124 kernel message ring buffer by a process without root
125 permissions.
126
127
128 __EINVAL__
129
130
131 Bad parameters.
132
133
134 __ERESTARTSYS__
135
136
137 System call was interrupted by a signal - nothing was
138 read.
139 !!CONFORMING TO
140
141
142 This system call is Linux specific and should not be used in
143 programs intended to be portable.
144 !!SEE ALSO
145
146
147 syslog(3)
148 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.