blob: 892812d97746bcb77c139af6888000fad43e8400 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
.\" -*- nroff -*-
.TH printk 9 "$Date:$" "Linux DDI" "Kernel Functions"
.SH NAME
printk \- print messages to console log
.SH SYNOPSIS
.B #include <linux/kernel.h>
.sp
.BI "int printk(const char*" fmt ", ...)"
.SH DESCRIPTION
Print a formatted message to the kernel console, much like the
.B printf
function of the stdio library. Normally, the message is written to the
physical console device of the computer, although this behavior can be
changed with the
.B register_console
function. Messages are also stored in a message log book.
.PP
The generated string may also start with a message priority code,
which sets the priority of the message. The priority code strings are
of the form
.I "<n>"
where n is a number from 0 - 7. The following macros are defined in
the
.I "<linux/kernel.h>"
header file:
.RS
.TP
KERN_EMERG
System is unuseable
.TP
KERN_ALERT
Action must be taken immediately
.TP
KERN_CRIT
Critical conditions
.TP
KERN_ERR
Error conditions
.TP
KERN_WARNING
Warning conditions
.TP
KERN_NOTICE
Normal but significant condition
.TP
KERN_INFO
Informational
.TP
KERN_DEBUG
Debug-level messages
.RE
For example
.nf
printk(KERN_NOTICE "Hello, world.\\n");
.fi
does the expected thing.
.SH "RETURN VALUE"
Returns the number of characters written to the log.
.SH AVAILABILITY
Linux 1.0+
.SH "SEE ALSO"
.BR register_console "(9), " syslog "(2)"
.PP
.IR "kernel/printk.c"
.SH AUTHOR
Stephen Williams (steve@icarus.com)
.SH BUGS
float and double formats are not supported. Floats and doubles do not
belong inside the kernel anyhow.
.PP
The
.B printk
implementation protects itself from interruption, so in principle it
can be used in interrupts handlers and critical sections. However,
there are no guarantees about the console function that is registered.
|