summaryrefslogtreecommitdiffstats
path: root/include/libzutil.h
diff options
context:
space:
mode:
authorTony Hutter <hutter2@llnl.gov>2019-12-19 16:26:07 -0800
committerBrian Behlendorf <behlendorf1@llnl.gov>2019-12-19 16:26:07 -0800
commit9fb2771aa5f53a14f8c30dca6b9f609d192e50f6 (patch)
treebe45f618051ea8a88ae5797fc011af775b002ee7 /include/libzutil.h
parent5e8ac0559046e8432bc7ae3232e4d4d746b09a4d (diff)
Colorize zpool status output
If the ZFS_COLOR env variable is set, then use ANSI color output in zpool status: - Column headers are bold - Degraded or offline pools/vdevs are yellow - Non-zero error counters and faulted vdevs/pools are red - The 'status:' and 'action:' sections are yellow if they're displaying a warning. This also includes a new 'faketty' function in libtest.shlib that is compatible with FreeBSD (code provided by @freqlabs). Reviewed-by: Jorgen Lundman <lundman@lundman.net> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #9340
Diffstat (limited to 'include/libzutil.h')
-rw-r--r--include/libzutil.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/libzutil.h b/include/libzutil.h
index 3dd4fcfb2..98998e195 100644
--- a/include/libzutil.h
+++ b/include/libzutil.h
@@ -146,6 +146,18 @@ extern int zpool_history_unpack(char *, uint64_t, uint64_t *, nvlist_t ***,
struct zfs_cmd;
int zfs_ioctl_fd(int fd, unsigned long request, struct zfs_cmd *zc);
+/*
+ * List of colors to use
+ */
+#define ANSI_RED "\033[0;31m"
+#define ANSI_YELLOW "\033[0;33m"
+#define ANSI_RESET "\033[0m"
+#define ANSI_BOLD "\033[1m"
+
+void color_start(char *color);
+void color_end(void);
+int printf_color(char *color, char *format, ...);
+
#ifdef __cplusplus
}
#endif