2 .\" Copyright (c) 2001 Andrew R. Reiter
3 .\" Copyright (c) 2004 Joerg Wunsch
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Nm printf , uprintf , tprintf, log
34 .Nd formatted output conversion
39 .Fn printf "const char *fmt" ...
41 .Fn tprintf "struct proc *p" "int pri" "const char *fmt" ...
43 .Fn uprintf "const char *fmt" ...
45 .Fn vprintf "const char *fmt" "va_list ap"
48 .Fn log "int pri" "const char *fmt" ...
50 .Fn vlog "int pri" "const char *fmt" "va_list ap"
54 family of functions are similar to the
57 The different functions each use a different output stream.
60 function outputs to the current process' controlling tty, while
62 writes to the console as well as to the logging facility.
65 function outputs to the tty associated with the process
67 and the logging facility if
72 function sends the message to the kernel logging facility, using
73 the log level as indicated by
75 and to the console if no process is yet reading the log.
77 Each of these related functions use the
79 parameter in the same manner as
83 adds two other conversion specifiers.
87 identifier expects two arguments: an
91 These are used as a register value and a print mask for decoding bitmasks.
92 The print mask is made up of two parts: the base and the
94 The base value is the output base expressed as an integer value;
95 for example, \e10 gives octal and \e20 gives hexadecimal.
96 The arguments are made up of a sequence of bit identifiers.
97 Each bit identifier begins with an integer value which is the number of the
98 bit (starting from 1) this identifier describes.
99 The rest of the identifier is a string of characters containing the name of
101 The string is terminated by either the bit number at the start of the next
104 for the last bit identifier.
108 identifier is meant to assist in hexdumps.
109 It requires two arguments: a
114 The memory pointed to be the pointer is output in hexadecimal one byte at
116 The string is used as a delimiter between individual bytes.
117 If present, a width directive will specify the number of bytes to display.
118 By default, 16 bytes of data are output.
130 parameter (mistakenly called
135 of \-1 is given, the message will be appended to the last log message
136 started by a previous call to
138 As these messages are generated by the kernel itself, the facility will
146 functions return the number of characters displayed.
148 This example demonstrates the use of the
152 conversion specifiers.
154 .Bd -literal -offset indent
159 printf("reg=%b\en", 3, "\e10\e2BITTWO\e1BITONE");
160 printf("out: %4D\en", "AAAA", ":");
164 will produce the following output:
165 .Bd -literal -offset indent
171 .Bd -literal -offset indent
172 log(LOG_DEBUG, "%s%d: been there.\en", sc->sc_name, sc->sc_unit);
175 will add the appropriate debug message at priority