Change log buffer butes to a symbolic const in runtime.
This commit is contained in:
parent
bdcb9d9b53
commit
fe1a4ab23c
5 changed files with 15 additions and 11 deletions
|
@ -22,14 +22,14 @@ last_os_error(rust_task *task) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#elif defined(_GNU_SOURCE)
|
#elif defined(_GNU_SOURCE)
|
||||||
char cbuf[1024];
|
char cbuf[BUF_BYTES];
|
||||||
char *buf = strerror_r(errno, cbuf, sizeof(cbuf));
|
char *buf = strerror_r(errno, cbuf, sizeof(cbuf));
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
task->fail(1);
|
task->fail(1);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char buf[1024];
|
char buf[BUF_BYTES];
|
||||||
int err = strerror_r(errno, buf, sizeof(buf));
|
int err = strerror_r(errno, buf, sizeof(buf));
|
||||||
if (err) {
|
if (err) {
|
||||||
task->fail(1);
|
task->fail(1);
|
||||||
|
|
|
@ -57,7 +57,7 @@ rust_dom::activate(rust_task *task) {
|
||||||
|
|
||||||
void
|
void
|
||||||
rust_dom::log(rust_task *task, uint32_t type_bits, char const *fmt, ...) {
|
rust_dom::log(rust_task *task, uint32_t type_bits, char const *fmt, ...) {
|
||||||
char buf[256];
|
char buf[BUF_BYTES];
|
||||||
if (_log.is_tracing(type_bits)) {
|
if (_log.is_tracing(type_bits)) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
@ -69,7 +69,7 @@ rust_dom::log(rust_task *task, uint32_t type_bits, char const *fmt, ...) {
|
||||||
|
|
||||||
void
|
void
|
||||||
rust_dom::log(uint32_t type_bits, char const *fmt, ...) {
|
rust_dom::log(uint32_t type_bits, char const *fmt, ...) {
|
||||||
char buf[256];
|
char buf[BUF_BYTES];
|
||||||
if (_log.is_tracing(type_bits)) {
|
if (_log.is_tracing(type_bits)) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
|
@ -88,6 +88,10 @@ static size_t const TIME_SLICE_IN_MS = 10;
|
||||||
|
|
||||||
static intptr_t const CONST_REFCOUNT = 0x7badface;
|
static intptr_t const CONST_REFCOUNT = 0x7badface;
|
||||||
|
|
||||||
|
// This accounts for logging buffers.
|
||||||
|
|
||||||
|
static size_t const BUF_BYTES = 1024;
|
||||||
|
|
||||||
// Every reference counted object should derive from this base class.
|
// Every reference counted object should derive from this base class.
|
||||||
|
|
||||||
template <typename T> struct rc_base {
|
template <typename T> struct rc_base {
|
||||||
|
|
|
@ -136,7 +136,7 @@ append_string(char *buffer, rust_log::ansi_color color,
|
||||||
|
|
||||||
void
|
void
|
||||||
rust_log::trace_ln(uint32_t thread_id, char *prefix, char *message) {
|
rust_log::trace_ln(uint32_t thread_id, char *prefix, char *message) {
|
||||||
char buffer[1024] = "";
|
char buffer[BUF_BYTES] = "";
|
||||||
_log_lock.lock();
|
_log_lock.lock();
|
||||||
append_string(buffer, "%-34s", prefix);
|
append_string(buffer, "%-34s", prefix);
|
||||||
for (uint32_t i = 0; i < _indent; i++) {
|
for (uint32_t i = 0; i < _indent; i++) {
|
||||||
|
@ -158,7 +158,7 @@ rust_log::trace_ln(rust_task *task, char *message) {
|
||||||
#else
|
#else
|
||||||
uint32_t thread_id = hash((uint32_t) pthread_self());
|
uint32_t thread_id = hash((uint32_t) pthread_self());
|
||||||
#endif
|
#endif
|
||||||
char prefix[1024] = "";
|
char prefix[BUF_BYTES] = "";
|
||||||
if (_dom && _dom->name) {
|
if (_dom && _dom->name) {
|
||||||
append_string(prefix, "%04" PRIxPTR ":%.10s:",
|
append_string(prefix, "%04" PRIxPTR ":%.10s:",
|
||||||
thread_id, _dom->name);
|
thread_id, _dom->name);
|
||||||
|
|
|
@ -12,7 +12,7 @@ rust_srv::rust_srv() :
|
||||||
}
|
}
|
||||||
|
|
||||||
rust_srv::~rust_srv() {
|
rust_srv::~rust_srv() {
|
||||||
// char msg[1024];
|
// char msg[BUF_BYTES];
|
||||||
// snprintf(msg, sizeof(msg), "~rust_srv %" PRIxPTR, (uintptr_t) this);
|
// snprintf(msg, sizeof(msg), "~rust_srv %" PRIxPTR, (uintptr_t) this);
|
||||||
// log(msg);
|
// log(msg);
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,13 @@ rust_srv::fatal(const char *expression,
|
||||||
size_t line,
|
size_t line,
|
||||||
const char *format,
|
const char *format,
|
||||||
...) {
|
...) {
|
||||||
char buf[1024];
|
char buf[BUF_BYTES];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsnprintf(buf, sizeof(buf), format, args);
|
vsnprintf(buf, sizeof(buf), format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
char msg[1024];
|
char msg[BUF_BYTES];
|
||||||
snprintf(msg, sizeof(msg),
|
snprintf(msg, sizeof(msg),
|
||||||
"fatal, '%s' failed, %s:%d %s",
|
"fatal, '%s' failed, %s:%d %s",
|
||||||
expression, file, (int)line, buf);
|
expression, file, (int)line, buf);
|
||||||
|
@ -63,13 +63,13 @@ rust_srv::warning(char const *expression,
|
||||||
size_t line,
|
size_t line,
|
||||||
const char *format,
|
const char *format,
|
||||||
...) {
|
...) {
|
||||||
char buf[1024];
|
char buf[BUF_BYTES];
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsnprintf(buf, sizeof(buf), format, args);
|
vsnprintf(buf, sizeof(buf), format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
char msg[1024];
|
char msg[BUF_BYTES];
|
||||||
snprintf(msg, sizeof(msg),
|
snprintf(msg, sizeof(msg),
|
||||||
"warning: '%s', at: %s:%d %s",
|
"warning: '%s', at: %s:%d %s",
|
||||||
expression, file, (int)line, buf);
|
expression, file, (int)line, buf);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue