summaryrefslogtreecommitdiff
path: root/src/basic/terminal-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-05-08 10:11:32 -0400
committerGitHub <noreply@github.com>2019-05-08 10:11:32 -0400
commite95be7def26c6c5feaf08a4135aa4f50c53263a8 (patch)
tree7c403e6690fd0071c3dfbf0a256a6b0b6c261f9b /src/basic/terminal-util.c
parentfd5e11f0bd747afd1d17f313949271022a1a13b2 (diff)
parent0d0464d39d78fc7db682313f14effb384da2256f (diff)
downloadsystemd-e95be7def26c6c5feaf08a4135aa4f50c53263a8.tar.gz
Merge pull request #12411 from keszybz/pr/12394
run: when emitting the calendarspec warning, use red
Diffstat (limited to 'src/basic/terminal-util.c')
-rw-r--r--src/basic/terminal-util.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index a2ea321243..cd878551f4 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -1310,3 +1310,41 @@ int vt_release(int fd, bool restore) {
return 0;
}
+
+void get_log_colors(int priority, const char **on, const char **off, const char **highlight) {
+ /* Note that this will initialize output variables only when there's something to output.
+ * The caller must pre-initalize to "" or NULL as appropriate. */
+
+ if (priority <= LOG_ERR) {
+ if (on)
+ *on = ANSI_HIGHLIGHT_RED;
+ if (off)
+ *off = ANSI_NORMAL;
+ if (highlight)
+ *highlight = ANSI_HIGHLIGHT;
+
+ } else if (priority <= LOG_WARNING) {
+ if (on)
+ *on = ANSI_HIGHLIGHT_YELLOW;
+ if (off)
+ *off = ANSI_NORMAL;
+ if (highlight)
+ *highlight = ANSI_HIGHLIGHT;
+
+ } else if (priority <= LOG_NOTICE) {
+ if (on)
+ *on = ANSI_HIGHLIGHT;
+ if (off)
+ *off = ANSI_NORMAL;
+ if (highlight)
+ *highlight = ANSI_HIGHLIGHT_RED;
+
+ } else if (priority >= LOG_DEBUG) {
+ if (on)
+ *on = ANSI_GREY;
+ if (off)
+ *off = ANSI_NORMAL;
+ if (highlight)
+ *highlight = ANSI_HIGHLIGHT_RED;
+ }
+}