Skip to content

Commit 75985ab

Browse files
committed
Remove color-related code from rust_log
This is all dead. If someone decides they want color it will be easy to redo.
1 parent 86f3374 commit 75985ab

File tree

2 files changed

+2
-48
lines changed

2 files changed

+2
-48
lines changed

src/rt/rust_log.cpp

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
2-
* Logging infrastructure that aims to support multi-threading,
3-
* and ansi colors.
2+
* Logging infrastructure that aims to support multi-threading
43
*/
54

65
#include "rust_internal.h"
@@ -9,13 +8,6 @@
98
#include <stdlib.h>
109
#include <string.h>
1110

12-
static const char * _foreground_colors[] = { "[37m",
13-
"[31m", "[1;31m",
14-
"[32m", "[1;32m",
15-
"[33m", "[1;33m",
16-
"[31m", "[1;31m",
17-
"[35m", "[1;35m",
18-
"[36m", "[1;36m" };
1911

2012
/**
2113
* Synchronizes access to the underlying logging mechanism.
@@ -25,8 +17,7 @@ static uint32_t _last_thread_id;
2517

2618
rust_log::rust_log(rust_srv *srv, rust_scheduler *sched) :
2719
_srv(srv),
28-
_sched(sched),
29-
_use_colors(getenv("RUST_COLOR_LOG")) {
20+
_sched(sched) {
3021
}
3122

3223
rust_log::~rust_log() {
@@ -45,11 +36,6 @@ hash(uintptr_t ptr) {
4536
return (uint16_t) ptr;
4637
}
4738

48-
const char *
49-
get_color(uintptr_t ptr) {
50-
return _foreground_colors[hash(ptr) % rust_log::LIGHTTEAL];
51-
}
52-
5339
char *
5440
copy_string(char *dst, const char *src, size_t length) {
5541
return strncpy(dst, src, length) + length;
@@ -67,21 +53,6 @@ append_string(char *buffer, const char *format, ...) {
6753
return buffer;
6854
}
6955

70-
char *
71-
append_string(char *buffer, rust_log::ansi_color color,
72-
const char *format, ...) {
73-
if (buffer != NULL && format) {
74-
append_string(buffer, "\x1b%s", _foreground_colors[color]);
75-
va_list args;
76-
va_start(args, format);
77-
size_t off = strlen(buffer);
78-
vsnprintf(buffer + off, BUF_BYTES - off, format, args);
79-
va_end(args);
80-
append_string(buffer, "\x1b[0m");
81-
}
82-
return buffer;
83-
}
84-
8556
void
8657
rust_log::trace_ln(uint32_t thread_id, char *prefix, char *message) {
8758
char buffer[BUF_BYTES] = "";

src/rt/rust_log.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,6 @@ class rust_log {
4141
rust_log(rust_srv *srv, rust_scheduler *sched);
4242
virtual ~rust_log();
4343

44-
enum ansi_color {
45-
WHITE,
46-
RED,
47-
LIGHTRED,
48-
GREEN,
49-
LIGHTGREEN,
50-
YELLOW,
51-
LIGHTYELLOW,
52-
BLUE,
53-
LIGHTBLUE,
54-
MAGENTA,
55-
LIGHTMAGENTA,
56-
TEAL,
57-
LIGHTTEAL
58-
};
59-
6044
void trace_ln(rust_task *task, uint32_t level, char *message);
6145
void trace_ln(uint32_t thread_id, char *prefix, char *message);
6246
bool is_tracing(uint32_t type_bits);
@@ -65,7 +49,6 @@ class rust_log {
6549
rust_srv *_srv;
6650
rust_scheduler *_sched;
6751
bool _use_labels;
68-
bool _use_colors;
6952
void trace_ln(rust_task *task, char *message);
7053
};
7154

0 commit comments

Comments
 (0)