1 .\" Copyright 2002 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" Distributed under GPL
3 .\" adapted glibc info page
5 .\" This should run as 'Guru Meditation' (amiga joke :)
6 .\" The function is quite complex an deserves an example
8 .\" Polished, aeb, 2003-11-01
9 .TH fmtmsg 3 2003-11-01 "" "Linux Programmer's Manual"
11 fmtmsg \- print formatted error messages
14 .B #include <fmtmsg.h>
16 .BI "int fmtmsg(long " classification ", const char *" label ,
18 .BI " int " severity ", const char *" text ,
20 .BI " const char *" action ", const char *" tag );
23 This function displays a message described by its parameters on the device(s)
27 For messages written to
29 the format depends on the
35 parameter identifies the source of the message.
36 The string must consist
37 of two colon separated parts where the first part has not more
38 than 10 and the second part not more than 14 characters.
42 parameter describes the condition of the error.
46 parameter describes possible steps to recover from the error.
47 If it is printed, it is prefixed by "TO FIX: ".
51 parameter is a reference to the online documentation where more
52 information can be found.
55 value and a unique identification number.
56 .SS "Dummy parameters"
57 Each of the parameters can have a dummy value.
58 The dummy classification value
60 (0L) does not specify any output, so nothing is printed.
61 The dummy severity value
63 (0) says that no severity is supplied.
69 are synonyms for ((char *) 0), the empty string, and
73 .SS "The classification parameter"
76 parameter is the sum of values describing 4 types of information.
79 The first value defines the output channel.
86 Output to the system console.
88 .B "MM_PRINT | MM_CONSOLE"
91 The second value is the source of the error:
94 A hardware error occurred.
97 A firmware error occurred.
100 A software error occurred.
102 The third value encodes the detector of the problem:
105 It is detected by an application.
108 It is detected by a utility.
111 It is detected by the operating system.
113 The fourth value shows the severity of the incident:
116 It is a recoverable error.
119 It is a non-recoverable error.
120 .SS "The severity parameter"
123 parameter can take one of the following values:
126 No severity is printed.
129 This value is printed as HALT.
132 This value is printed as ERROR.
135 This value is printed as WARNING.
138 This value is printed as INFO.
140 The numeric values are between 0 and 4.
143 or the environment variable
145 you can add more levels and strings to print.
147 The environment variable
149 ("message verbosity") can be used to suppress parts of
152 (It does not influence output to the console.)
153 When this variable is defined, is non-NULL, and is a colon-separated
154 list of valid keywords, then only the parts of the message corresponding
155 to these keywords is printed.
156 Valid keywords are "label", "severity", "text", "action" and "tag".
158 The environment variable
160 can be used to introduce new severity levels.
161 By default, only the five severity levels described
163 Any other numeric value would make
171 SEV_LEVEL=[description[:description[:...]]]
174 in the environment of the process before the first call to
176 where each description is of the form
179 severity-keyword,level,printstring
184 will also accept the indicated values for the level (in addition to
185 the standard levels 0-4), and use the indicated printstring when
188 The severity-keyword part is not used by
190 but it has to be present.
191 The level part is a string representation of a number.
192 The numeric value must be a number greater than 4.
193 This value must be used in the severity parameter of
195 to select this class.
196 It is not possible to overwrite
197 any of the predefined classes.
199 is the string printed when a message of this class is processed by
202 The function can return 4 values:
205 Everything went smooth.
215 Error writing to the console.
221 and environment variables
228 and the environment variable
230 are described in POSIX.1-2001.
232 System V and Unixware man pages tell us that these functions
233 have been replaced by "pfmt() and addsev()" or by "pfmt(),
234 vpfmt(), lfmt(), and vlfmt()", and will be removed later.
243 long class = MM_PRINT | MM_SOFT | MM_OPSYS | MM_RECOVER;
245 err = fmtmsg(class, "util-linux:mount", MM_ERROR,
246 "unknown mount option", "See mount(8).",
247 "util-linux:mount:017");
252 printf("Nothing printed\en");
255 printf("Nothing printed to stderr\en");
258 printf("No console output\en");
261 printf("Unknown error from fmtmsg()\en");
267 The output should be:
269 util-linux:mount: ERROR: unknown mount option
270 TO FIX: See mount(8). util-linux:mount:017
274 MSGVERB=text:action; export MSGVERB
279 TO FIX: See mount(8).