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 and deserves an example
8 .\" Polished, aeb, 2003-11-01
10 .\" Japanese Version Copyright (c) 2004 Yuichi SATO
11 .\" all rights reserved.
12 .\" Translated Sat Jul 24 20:19:54 JST 2004
13 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
15 .TH FMTMSG 3 2008-06-14 "" "Linux Programmer's Manual"
18 .\"O fmtmsg \- print formatted error messages
19 fmtmsg \- À°·Á¤µ¤ì¤¿¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë
23 .B #include <fmtmsg.h>
25 .BI "int fmtmsg(long " classification ", const char *" label ,
27 .BI " int " severity ", const char *" text ,
29 .BI " const char *" action ", const char *" tag );
33 .\"O This function displays a message described by its arguments on the device(s)
35 .\"O .I classification
37 .\"O For messages written to
39 .\"O the format depends on the
41 .\"O environment variable.
42 ¤³¤Î´Ø¿ô¤Ï¡¢°ú¤¿ô¤Çµ½Ò¤µ¤ì¤¿¥á¥Ã¥»¡¼¥¸¤ò¡¢
44 °ú¤¿ô¤Ç»ØÄꤵ¤ì¤¿¥Ç¥Ð¥¤¥¹¾å¤Ëɽ¼¨¤¹¤ë¡£
46 ¤Ë½ñ¤½Ð¤µ¤ì¤ë¥á¥Ã¥»¡¼¥¸¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï¡¢
52 .\"O argument identifies the source of the message.
53 .\"O The string must consist
54 .\"O of two colon separated parts where the first part has not more
55 .\"O than 10 and the second part not more than 14 characters.
57 °ú¤¿ô¤Ï¥á¥Ã¥»¡¼¥¸¤ÎȯÀ¸¸»¤ò¼±Ê̤¹¤ë¡£
58 ¤³¤Îʸ»úÎó¤Ï¥³¥í¥ó¤Ç¶èÀÚ¤é¤ì¤¿ 2 ¤Ä¤ÎÉôʬ¤«¤é¹½À®¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
59 1 ¤ÄÌܤÎÉôʬ¤Ï 10 ʸ»ú°ÊÆâ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢
60 2 ¤ÄÌܤÎÉôʬ¤Ï 14 ʸ»ú°ÊÆâ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
64 .\"O argument describes the condition of the error.
66 °ú¤¿ô¤Ë¤Ï¥¨¥é¡¼¾ò·ï¤òµ½Ò¤¹¤ë¡£
70 .\"O argument describes possible steps to recover from the error.
71 .\"O If it is printed, it is prefixed by "TO FIX: ".
73 °ú¤¿ô¤Ë¤Ï¥¨¥é¡¼¤«¤é²óÉü¤¹¤ë¤¿¤á¤ËÍøÍѲÄǽ¤Ê¥¹¥Æ¥Ã¥×¤òµ½Ò¤¹¤ë¡£
74 ¤³¤ì¤¬É½¼¨¤µ¤ì¤ë¾ì¹ç¡¢"TO FIX: " ¤¬Á°¤ËÉÕ¤¯¡£
78 .\"O argument is a reference to the online documentation where more
79 .\"O information can be found.
80 .\"O It should contain the
82 .\"O value and a unique identification number.
84 °ú¤¿ô¤Ï¤è¤ê¿¤¯¤Î¾ðÊó¤ò¸«¤Ä¤±¤ë¤¿¤á¤Î¥ª¥ó¥é¥¤¥ó¥É¥¥å¥á¥ó¥È¤Ø¤Î»²¾È¤Ç¤¢¤ë¡£
87 Ãͤȥæ¥Ë¡¼¥¯¤Ê¼±ÊÌÈÖ¹æ¤ò´Þ¤ó¤Ç¤¤¤ë¤Ù¤¤Ç¤¢¤ë¡£
88 .\"O .SS "Dummy arguments"
90 .\"O Each of the arguments can have a dummy value.
91 .\"O The dummy classification value
93 .\"O (0L) does not specify any output, so nothing is printed.
94 ³Æ°ú¤¿ô¤Ë¤Ï¥À¥ß¡¼¤ÎÃͤòÆþ¤ì¤ë¤³¤È¤¬¤Ç¤¤ë¡£
99 (0L) ¤Ï½ÐÎϤò²¿¤â»ØÄꤷ¤Ê¤¤¡£¤½¤Î¤¿¤á²¿¤âɽ¼¨¤µ¤ì¤Ê¤¤¡£
100 .\"O The dummy severity value
102 .\"O (0) says that no severity is supplied.
107 (0) ¤Ï½ÅÂçÅÙ (severity) ¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤Ê¤¤¤³¤È¤òɽ¤¹¡£
109 .\"O .BR MM_NULLLBL ,
110 .\"O .BR MM_NULLTXT ,
111 .\"O .BR MM_NULLACT ,
113 .\"O are synonyms for
114 .\"O .IR "((char *) 0)" ,
115 .\"O the empty string, and
117 .\"O is a synonym for
126 ¤È¶õʸ»úÎó¤ÎÊÌ̾¤Ç¤¢¤ê¡¢
131 .\"O .SS "The classification argument"
132 .SS "classification °ú¤¿ô"
134 .\"O .I classification
135 .\"O argument is the sum of values describing 4 types of information.
137 °ú¤¿ô¤Ï 4 ¼ïÎà¤Î¾ðÊó¤òµ½Ò¤¹¤ëÃͤÎϤǤ¢¤ë¡£
140 .\"O The first value defines the output channel.
141 ºÇ½é¤ÎÃͤϽÐÎÏ¥Á¥ã¥ó¥Í¥ë¤òÄêµÁ¤¹¤ë¡£
150 .\"O Output to the system console.
151 ¥·¥¹¥Æ¥à¥³¥ó¥½¡¼¥ë¤Ë½ÐÎϤ¹¤ë¡£
153 .B "MM_PRINT | MM_CONSOLE"
157 .\"O The second value is the source of the error:
158 2 ÈÖÌܤÎÃͤϥ¨¥é¡¼¤ÎȯÀ¸¸»¤Ç¤¢¤ë:
161 .\"O A hardware error occurred.
162 ¥Ï¡¼¥É¥¦¥§¥¢¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
165 .\"O A firmware error occurred.
166 ¥Õ¥¡¡¼¥à¥¦¥§¥¢¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
169 .\"O A software error occurred.
170 ¥½¥Õ¥È¥¦¥§¥¢¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
172 .\"O The third value encodes the detector of the problem:
173 3 ÈÖÌܤÎÃͤÏÌäÂê¤Î¸¡ÃΤò¹Ô¤Ã¤¿¤â¤Î¤ò¥¨¥ó¥³¡¼¥É¤¹¤ë:
176 .\"O It is detected by an application.
177 ¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ë¤è¤Ã¤Æ¸¡ÃΤµ¤ì¤¿¡£
180 .\"O It is detected by a utility.
181 ¥æ¡¼¥Æ¥£¥ê¥Æ¥£¤Ë¤è¤Ã¤Æ¸¡ÃΤµ¤ì¤¿¡£
184 .\"O It is detected by the operating system.
185 ¥ª¥Ú¥ì¡¼¥Æ¥£¥ó¥°¥·¥¹¥Æ¥à¤Ë¤è¤Ã¤Æ¸¡ÃΤµ¤ì¤¿¡£
187 .\"O The fourth value shows the severity of the incident:
188 4 ÈÖÌܤÎÃͤÏÌäÂê¤Î½ÅÂçÅÙ¤òɽ¤¹:
191 .\"O It is a recoverable error.
192 ²óÉü²Äǽ¤Ê¥¨¥é¡¼¤Ç¤¢¤ë¡£
195 .\"O It is a nonrecoverable error.
196 ²óÉüÉÔ²Äǽ¤Ê¥¨¥é¡¼¤Ç¤¢¤ë¡£
197 .\"O .SS "The severity argument"
198 .SS "severity °ú¤¿ô"
201 .\"O argument can take one of the following values:
203 °ú¤¿ô¤Ï°Ê²¼¤Î 1 ¤Ä¤ÎÃͤò¤È¤ë¤³¤È¤¬¤Ç¤¤ë¡£
206 .\"O No severity is printed.
207 ½ÅÂçÅÙ¤Ïɽ¼¨¤µ¤ì¤Ê¤¤¡£
210 .\"O This value is printed as HALT.
211 ¤³¤ÎÃÍ¤Ï HALT ¤È¤·¤Æɽ¼¨¤µ¤ì¤ë¡£
214 .\"O This value is printed as ERROR.
215 ¤³¤ÎÃÍ¤Ï ERROR ¤È¤·¤Æɽ¼¨¤µ¤ì¤ë¡£
218 .\"O This value is printed as WARNING.
219 ¤³¤ÎÃÍ¤Ï WARNING ¤È¤·¤Æɽ¼¨¤µ¤ì¤ë¡£
222 .\"O This value is printed as INFO.
223 ¤³¤ÎÃÍ¤Ï INFO ¤È¤·¤Æɽ¼¨¤µ¤ì¤ë¡£
225 .\"O The numeric values are between 0 and 4.
227 .\"O .BR addseverity (3)
228 .\"O or the environment variable
230 .\"O you can add more levels and strings to print.
231 ¿ôÃͤξì¹ç¤Ï 0 ¤«¤é 4 ¤Ç¤¢¤ë¡£
235 ¤ò»È¤¦¤³¤È¤Ë¤è¤ê¡¢É½¼¨¤¹¤ë¥ì¥Ù¥ë¤Èʸ»úÎó¤ò¹¹¤ËÄɲäǤ¤ë¡£
236 .\"O .SH "RETURN VALUE"
238 .\"O The function can return 4 values:
239 ´Ø¿ô¤Ï 4 ¤Ä¤ÎÃͤòÊÖ¤¹:
242 .\"O Everything went smooth.
246 .\"O Complete failure.
250 .\"O Error writing to
253 ¤Ë½ñ¤¹þ¤à¤È¤¤Ë¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
256 .\"O Error writing to the console.
257 ¥³¥ó¥½¡¼¥ë¤Ë½ñ¤¹þ¤à¤È¤¤Ë¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
260 .\"O The environment variable
262 .\"O ("message verbosity") can be used to suppress parts of
267 ("message verbosity") ¤Ï
269 ¤Ø¤Î½ÐÎϤΰìÉô¤òÍÞÀ©¤¹¤ë¤Î¤Ë»È¤¦¤³¤È¤¬¤Ç¤¤ë¡£
270 .\"O (It does not influence output to the console.)
271 (¥³¥ó¥½¡¼¥ë¤Ø¤Î½ÐÎϤˤϱƶÁ¤·¤Ê¤¤¡£)
272 .\"O When this variable is defined, is non-NULL, and is a colon-separated
273 .\"O list of valid keywords, then only the parts of the message corresponding
274 .\"O to these keywords is printed.
275 ¤³¤ÎÊÑ¿ô¤¬ÄêµÁ¤µ¤ì¤Æ¡¢NULL ¤Ç¤Ê¤¯¡¢
276 ¥³¥í¥ó¤Ç¶èÀÚ¤é¤ì¤¿Í¸ú¤Ê¥¡¼¥ï¡¼¥É¤Î¥ê¥¹¥È¤Ç¤¢¤ë¾ì¹ç¡¢
277 ¥¡¼¥ï¡¼¥É¤ËÂбþ¤¹¤ë¥á¥Ã¥»¡¼¥¸¤Î°ìÉô¤Î¤ß¤¬É½¼¨¤µ¤ì¤ë¡£
278 .\"O Valid keywords are "label", "severity", "text", "action" and "tag".
279 ͸ú¤Ê¥¡¼¥ï¡¼¥É¤Ï "label", "severity", "text", "action", "tag" ¤Ç¤¢¤ë¡£
281 .\"O The environment variable
283 .\"O can be used to introduce new severity levels.
286 ¤Ï¿·¤·¤¤½ÅÂçÅÙ¥ì¥Ù¥ë¤òƳÆþ¤¹¤ë¤Î¤Ë»ÈÍѤǤ¤ë¡£
287 .\"O By default, only the five severity levels described
288 .\"O above are available.
289 .\"O Any other numeric value would make
292 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢¾åµ¤Î 5 ¤Ä¤Î½ÅÂçÅÙ¥ì¥Ù¥ë¤Î¤ß¤¬ÍøÍѲÄǽ¤Ç¤¢¤ë¡£
296 .\"O If the user puts
298 .\"O with a format like
301 .\"O SEV_LEVEL=[description[:description[:...]]]
304 .\"O in the environment of the process before the first call to
306 .\"O where each description is of the form
309 .\"O severity-keyword,level,printstring
314 .\"O will also accept the indicated values for the level (in addition to
315 .\"O the standard levels 0-4), and use the indicated printstring when
316 .\"O such a level occurs.
318 ¤ò½é¤á¤Æ¸Æ¤Ó½Ð¤¹Á°¤Ë¡¢¥æ¡¼¥¶¤¬
323 SEV_LEVEL=[description[:description[:...]]]
326 ¤Î¤è¤¦¤Ê·Á¼°¤Ç¥×¥í¥»¥¹¤Î´Ä¶¤ËÀßÄꤹ¤ë¤È¡¢
328 ¤Ï (ɸ½à¤Î¥ì¥Ù¥ë 0-4 ¤Ë²Ã¤¨¤Æ) level ¤Ë»ØÄꤵ¤ì¤¿Ãͤâ¼õ¤±ÉÕ¤±¡¢
329 ¤½¤Î¤è¤¦¤Ê¥ì¥Ù¥ë¤ÎÌäÂ꤬ȯÀ¸¤¹¤ë¤È»ØÄꤵ¤ì¤¿ printstring ¤òɽ¼¨¤¹¤ë¡£
333 severity-keyword,level,printstring
338 .\"O The severity-keyword part is not used by
340 .\"O but it has to be present.
341 severity-keyword Éô¤Ï
343 ¤Ë»ÈÍѤµ¤ì¤Ê¤¤¤¬¡¢Â¸ºß¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
344 .\"O The level part is a string representation of a number.
345 level Éô¤Ï¿ôÃͤòʸ»úÎó¤Çɽ¤·¤¿¤â¤Î¤Ç¤¢¤ë¡£
346 .\"O The numeric value must be a number greater than 4.
347 ¿ôÃÍ¤Ï 4 ¤è¤êÂ礤¤ÃͤǤʤ±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
348 .\"O This value must be used in the severity argument of
350 .\"O to select this class.
351 .\"O It is not possible to overwrite
352 .\"O any of the predefined classes.
354 .\"O is the string printed when a message of this class is processed by
358 ¤Î severity °ú¤¿ô¤Ç»ÈÍѤµ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢¤³¤Î½ÅÂçÅÙ¤òÁªÂò¤¹¤ë¡£
359 Á°¤â¤Ã¤ÆÀë¸À¤µ¤ì¤¿½ÅÂçÅÙ¤ò¾å½ñ¤¤¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¡£
361 ¤³¤Î½ÅÂçÅ٤Υá¥Ã¥»¡¼¥¸¤¬
363 ¤Ë¤è¤Ã¤ÆÀ¸À®¤µ¤ì¤¿¾ì¹ç¤Ëɽ¼¨¤µ¤ì¤ëʸ»úÎó¤Ç¤¢¤ë¡£
367 .\"O is provided in glibc since version 2.1.
369 ¤Ï¡¢¥Ð¡¼¥¸¥ç¥ó 2.1 °Ê¹ß¤Î glibc ¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
370 .\"O .SH "CONFORMING TO"
375 .\"O .BR addseverity (3),
376 .\"O and environment variables
380 .\"O come from System V.
389 ¤Ï System V ¤ËͳÍ褷¤Æ¤¤¤ë¡£
392 .\"O and the environment variable
394 .\"O are described in POSIX.1-2001.
399 ¤Ï POSIX.1-2001 ¤Ëµ½Ò¤µ¤ì¤Æ¤¤¤ë¡£
402 .\"O System V and UnixWare man pages tell us that these functions
403 .\"O have been replaced by "pfmt() and addsev()" or by "pfmt(),
404 .\"O vpfmt(), lfmt(), and vlfmt()", and will be removed later.
405 System V ¤È UnixWare ¤Î man ¥Ú¡¼¥¸¤Ë¤Ï¡¢
406 ¡Ö¤³¤ì¤é¤Î´Ø¿ô¤Ï "pfmt() ¤È addsev()"
407 ¤Þ¤¿¤Ï "pfmt(), vpfmt(), lfmt(), vlfmt()" ¤ÇÃÖ¤´¹¤¨¤é¤ì¤Æ¤ª¤ê¡¢
408 ¾Íè¤Ïºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¢¤ë¡×¤È½ñ¤«¤ì¤Æ¤¤¤ë¡£
419 long class = MM_PRINT | MM_SOFT | MM_OPSYS | MM_RECOVER;
422 err = fmtmsg(class, "util\-linux:mount", MM_ERROR,
423 "unknown mount option", "See mount(8).",
424 "util\-linux:mount:017");
429 printf("Nothing printed\en");
432 printf("Nothing printed to stderr\en");
435 printf("No console output\en");
438 printf("Unknown error from fmtmsg()\en");
444 .\"O The output should be:
448 util\-linux:mount: ERROR: unknown mount option
449 TO FIX: See mount(8). util\-linux:mount:017
456 MSGVERB=text:action; export MSGVERB
459 .\"O the output becomes:
464 TO FIX: See mount(8).