xref: /illumos-gate/usr/src/cmd/fm/fmdump/common/error.c (revision 93a18d6d401e844455263f926578e9d2aa6b47ec)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #include <fmdump.h>
27 #include <stdio.h>
28 #include <time.h>
29 
30 /*ARGSUSED*/
31 static int
32 err_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
33 {
34 	char buf[32];
35 
36 	fmdump_printf(fp, "%-20s %-32s\n",
37 	    fmdump_date(buf, sizeof (buf), rp), rp->rec_class);
38 
39 	return (0);
40 }
41 
42 /*ARGSUSED*/
43 static int
44 err_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
45 {
46 	uint64_t ena = 0;
47 	char buf[32];
48 
49 	(void) nvlist_lookup_uint64(rp->rec_nvl, FM_EREPORT_ENA, &ena);
50 
51 	fmdump_printf(fp, "%-20s %-37s 0x%016llx\n",
52 	    fmdump_date(buf, sizeof (buf), rp), rp->rec_class, ena);
53 
54 	return (0);
55 }
56 
57 /*ARGSUSED*/
58 static int
59 err_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
60 {
61 	char buf[32];
62 
63 	fmdump_printf(fp, "%-20s.%9.9llu %s\n",
64 	    fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, rp->rec_class);
65 
66 	nvlist_print(fp, rp->rec_nvl);
67 	fmdump_printf(fp, "\n");
68 	return (0);
69 }
70 
71 const fmdump_ops_t fmdump_err_ops = {
72 "error", {
73 {
74 "TIME                 CLASS",
75 (fmd_log_rec_f *)err_short
76 }, {
77 "TIME                 CLASS                                 ENA",
78 (fmd_log_rec_f *)err_verb1
79 }, {
80 "TIME                           CLASS",
81 (fmd_log_rec_f *)err_verb2
82 }, {
83 NULL, NULL
84 } }
85 };
86