Colorization concerns only comments displayed in CSV and RAW formats.
It also concerns some hints displayed in RAW format in debug mode.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
else if (type == IS_ZERO) {
printf("%s", sc_zero_int_stat);
}
+ /* IS_RESTART and IS_DEBUG are the same value */
else if (type == IS_RESTART) {
printf("%s", sc_sa_restart);
}
#define IS_INT 0
#define IS_STR 1
#define IS_RESTART 2
+#define IS_DEBUG IS_RESTART
#define IS_COMMENT 3
#define IS_ZERO 4
if (DISPLAY_DEBUG_MODE(flags)) {
if (valc < valp) {
/* Field's value has decreased */
- printf(" [DEC]");
+ cprintf_s(IS_DEBUG, "%s", " [DEC]");
}
}
printf("; %llu; %llu;", valp, valc);
scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
scc->cpu_hardirq + scc->cpu_softirq) == 0) {
/* CPU is offline */
- printf(" [OFF]");
+ cprintf_s(IS_DEBUG, "%s", " [OFF]");
}
else {
if (!get_per_cpu_interval(scc, scp)) {
/* CPU is tickless */
- printf(" [TLS]");
+ cprintf_s(IS_DEBUG, "%s", " [TLS]");
}
}
}
printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
if (!found && DISPLAY_DEBUG_MODE(flags)) {
- printf(" [NEW]");
+ cprintf_s(IS_DEBUG, "%s", " [NEW]");
}
printf("; %u;", ssc->line);
if (!found) {
/* This is a newly registered interface. Previous stats are zero */
sdp = &sdpzero;
if (DISPLAY_DEBUG_MODE(flags)) {
- printf(" [%s]", j == -1 ? "NEW" : "BCK");
+ cprintf_s(IS_DEBUG, "%s", j == -1 ? " [NEW]" : " [BCK]");
}
}
else {
/* This is a newly registered interface. Previous stats are zero */
sndp = &sndzero;
if (DISPLAY_DEBUG_MODE(flags)) {
- printf(" [%s]", j == -1 ? "NEW" : "BCK");
+ cprintf_s(IS_DEBUG, "%s", j == -1 ? " [NEW]" : " [BCK]");
}
}
else {
/* This is a newly registered interface. Previous stats are zero */
snedp = &snedzero;
if (DISPLAY_DEBUG_MODE(flags)) {
- printf(" [%s]", j == -1 ? "NEW" : "BCK");
+ cprintf_s(IS_DEBUG, "%s", j == -1 ? " [NEW]" : " [BCK]");
}
}
else {
/* This is a newly registered host. Previous stats are zero */
sfcp = &sfczero;
if (DISPLAY_DEBUG_MODE(flags)) {
- printf(" [NEW]");
+ cprintf_s(IS_DEBUG, "%s", " [NEW]");
}
}
if (ssnc->processed + ssnc->dropped + ssnc->time_squeeze +
ssnc->received_rps + ssnc->flow_limit == 0) {
/* CPU is considered offline */
- printf(" [OFF]");
+ cprintf_s(IS_DEBUG, "%s", " [OFF]");
}
}
printf("; %d;", i - 1);
/* Raw output in debug mode */
if (DISPLAY_DEBUG_MODE(flags) && (ofmt->id == F_RAW_OUTPUT)) {
- printf("# uptime_cs; %llu; ust_time; %llu; extra_next; %u; record_type; %d; HH:MM:SS; %02d:%02d:%02d\n",
+ char out[128];
+
+ sprintf(out, "# uptime_cs; %llu; ust_time; %llu; extra_next; %u; record_type; %d; HH:MM:SS; %02d:%02d:%02d\n",
record_hdr->uptime_cs, record_hdr->ust_time,
record_hdr->extra_next, record_hdr->record_type,
record_hdr->hour, record_hdr->minute, record_hdr->second);
+ cprintf_s(IS_COMMENT, "%s", out);
}
/* Sanity checks */
unsigned int msk;
char *hl;
char hline[HEADER_LINE_LEN] = "";
+ char out[256];
- printf("# hostname;interval;timestamp");
+ cprintf_s(IS_COMMENT, "%s", "# hostname;interval;timestamp");
for (i = 0; i < NR_ACT; i++) {
if (IS_SELECTED(act[i]->options) && (act[i]->nr_ini > 0)) {
if (!HAS_MULTIPLE_OUTPUTS(act[i]->options)) {
- printf(";%s", act[i]->hdr_line);
+ sprintf(out, ";%s", act[i]->hdr_line);
+ cprintf_s(IS_COMMENT, "%s", out);
if ((act[i]->nr_ini > 1) && DISPLAY_HORIZONTALLY(flags)) {
- printf("[...]");
+ cprintf_s(IS_COMMENT, "%s", "[...]");
}
}
else {
if ((act[i]->opt_flags & 0xff00) & (msk << 8)) {
/* Display whole header line */
*(hl + j) = ';';
- printf(";%s", hl);
+ sprintf(out, ";%s", hl);
+ cprintf_s(IS_COMMENT, "%s", out);
}
else {
/* Display only the first part of the header line */
*(hl + j) = '\0';
- printf(";%s", hl);
+ sprintf(out, ";%s", hl);
+ cprintf_s(IS_COMMENT, "%s", out);
}
*(hl + j) = '&';
}
else {
- printf(";%s", hl);
+ sprintf(out, ";%s", hl);
+ cprintf_s(IS_COMMENT, "%s", out);
}
if ((act[i]->nr_ini > 1) && DISPLAY_HORIZONTALLY(flags)) {
- printf("[...]");
+ cprintf_s(IS_COMMENT, "%s", "[...]");
}
}
}
else if (format == F_RAW_OUTPUT) {
/* Raw output */
if (DISPLAY_DEBUG_MODE(flags)) {
- printf("# name; %s; nr_curr; %d; nr_alloc; %d; nr_ini; %d\n", act[i]->name,
- act[i]->nr[curr], act[i]->nr_allocated, act[i]->nr_ini);
+ char out[128];
+
+ sprintf(out, "# name; %s; nr_curr; %d; nr_alloc; %d; nr_ini; %d\n",
+ act[i]->name, act[i]->nr[curr], act[i]->nr_allocated,
+ act[i]->nr_ini);
+ cprintf_s(IS_COMMENT, "%s", out);
}
if (IS_SELECTED(act[i]->options) && (act[i]->nr[curr] > 0)) {
}
}
+ /* Init color strings */
+ init_colors();
+
if (USE_OPTION_A(flags)) {
/* Set -P ALL -I ALL if needed */
set_bitmaps(act, &flags);