xref: /titanic_52/usr/src/cmd/fm/fmdump/common/error.c (revision 7eea693d6b672899726e75993fddc4e95b52647f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 #include <fmdump.h>
29 #include <stdio.h>
30 #include <time.h>
31 
32 /*ARGSUSED*/
33 static int
34 err_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
35 {
36 	char buf[32];
37 
38 	fmdump_printf(fp, "%-20s %-32s\n",
39 	    fmdump_date(buf, sizeof (buf), rp), rp->rec_class);
40 
41 	return (0);
42 }
43 
44 /*ARGSUSED*/
45 static int
46 err_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
47 {
48 	uint64_t ena = 0;
49 	char buf[32];
50 
51 	(void) nvlist_lookup_uint64(rp->rec_nvl, FM_EREPORT_ENA, &ena);
52 
53 	fmdump_printf(fp, "%-20s %-37s 0x%016llx\n",
54 	    fmdump_date(buf, sizeof (buf), rp), rp->rec_class, ena);
55 
56 	return (0);
57 }
58 
59 /*ARGSUSED*/
60 static int
61 err_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
62 {
63 	char buf[32];
64 
65 	fmdump_printf(fp, "%-20s.%9.9llu %s\n",
66 	    fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, rp->rec_class);
67 
68 	nvlist_print(fp, rp->rec_nvl);
69 	fmdump_printf(fp, "\n");
70 	return (0);
71 }
72 
73 const fmdump_ops_t fmdump_err_ops = {
74 "error", {
75 {
76 "TIME                 CLASS",
77 (fmd_log_rec_f *)err_short
78 }, {
79 "TIME                 CLASS                                 ENA",
80 (fmd_log_rec_f *)err_verb1
81 }, {
82 "TIME                           CLASS",
83 (fmd_log_rec_f *)err_verb2
84 } }
85 };
86