diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-08-28 01:33:48 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-09-25 16:30:05 -0700 |
| commit | eb2b25dd6d38157213742b048fad63fa4ceec691 (patch) | |
| tree | e41f9af78454e8f6641dead395274419d843ab63 /src/libsyntax | |
| parent | af25f58ac3da45899ed65b3af965150c8a90dcda (diff) | |
| download | rust-eb2b25dd6d38157213742b048fad63fa4ceec691.tar.gz rust-eb2b25dd6d38157213742b048fad63fa4ceec691.zip | |
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.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 64f30803ca7..80cb9424fa1 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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)+) } }) ) |
