dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / cmd / fm / fmdump / common / error.c
bloba8c849993e6e3e37604a51c74f58d93df4673c10
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
26 #include <fmdump.h>
27 #include <stdio.h>
28 #include <time.h>
30 /*ARGSUSED*/
31 static int
32 err_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
34 char buf[32];
36 fmdump_printf(fp, "%-20s %-32s\n",
37 fmdump_date(buf, sizeof (buf), rp), rp->rec_class);
39 return (0);
42 /*ARGSUSED*/
43 static int
44 err_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
46 uint64_t ena = 0;
47 char buf[32];
49 (void) nvlist_lookup_uint64(rp->rec_nvl, FM_EREPORT_ENA, &ena);
51 fmdump_printf(fp, "%-20s %-37s 0x%016llx\n",
52 fmdump_date(buf, sizeof (buf), rp), rp->rec_class, ena);
54 return (0);
57 /*ARGSUSED*/
58 static int
59 err_verb23_cmn(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp,
60 nvlist_prtctl_t pctl)
62 char buf[32];
64 fmdump_printf(fp, "%-20s.%9.9llu %s\n",
65 fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, rp->rec_class);
67 if (pctl)
68 nvlist_prt(rp->rec_nvl, pctl);
69 else
70 nvlist_print(fp, rp->rec_nvl);
72 fmdump_printf(fp, "\n");
73 return (0);
76 static int
77 err_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
79 return (err_verb23_cmn(lp, rp, fp, NULL));
82 static int
83 err_pretty(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
85 nvlist_prtctl_t pctl;
86 int rc;
88 if ((pctl = nvlist_prtctl_alloc()) != NULL) {
89 nvlist_prtctl_setdest(pctl, fp);
90 nvlist_prtctlop_nvlist(pctl, fmdump_render_nvlist, NULL);
93 rc = err_verb23_cmn(lp, rp, fp, pctl);
95 nvlist_prtctl_free(pctl);
96 return (rc);
99 const fmdump_ops_t fmdump_err_ops = {
100 "error", {
102 "TIME CLASS",
103 (fmd_log_rec_f *)err_short
104 }, {
105 "TIME CLASS ENA",
106 (fmd_log_rec_f *)err_verb1
107 }, {
108 "TIME CLASS",
109 (fmd_log_rec_f *)err_verb2
110 }, {
111 "TIME CLASS",
112 (fmd_log_rec_f *)err_pretty
113 }, {
114 NULL, NULL
115 }, {
116 NULL,
117 (fmd_log_rec_f *)fmdump_print_json