Refactor the logging system for fewer allocations

This lifts various restrictions on the runtime, for example the character limit
when logging a message. Right now the old debug!-style macros still involve
allocating (because they use fmt! syntax), but the new debug2! macros don't
involve allocating at all (unless the formatter for a type requires allocation.
This commit is contained in:
Alex Crichton 2013-08-28 01:33:48 -07:00
parent af25f58ac3
commit eb2b25dd6d
7 changed files with 83 additions and 138 deletions

View file

@ -813,13 +813,17 @@ pub fn std_macros() -> @str {
($lvl:expr, $arg:expr) => ({
let lvl = $lvl;
if lvl <= __log_level() {
::std::logging::log(lvl, fmt!(\"%?\", $arg))
format_args!(|args| {
::std::logging::log(lvl, args)
}, \"{}\", fmt!(\"%?\", $arg))
}
});
($lvl:expr, $($arg:expr),+) => ({
let lvl = $lvl;
if lvl <= __log_level() {
::std::logging::log(lvl, fmt!($($arg),+))
format_args!(|args| {
::std::logging::log(lvl, args)
}, \"{}\", fmt!($($arg),+))
}
})
)
@ -834,7 +838,9 @@ pub fn std_macros() -> @str {
($lvl:expr, $($arg:tt)+) => ({
let lvl = $lvl;
if lvl <= __log_level() {
::std::logging::log(lvl, format!($($arg)+))
format_args!(|args| {
::std::logging::log(lvl, args)
}, $($arg)+)
}
})
)