提交 695e9fd1 编写于 作者: B bors

auto merge of #5293 : brson/rust/logging, r=brson

r? @graydon

This removes `log` from the language. Because we can't quite implement it as a syntax extension (probably need globals at the least) it simply renames the keyword to `__log` and hides it behind macros.

After this the only way to log is with `debug!`, `info!`, etc. I figure that if there is demand for `log!` we can add it back later.

I am not sure that we ever agreed on this course of action, though I *think* there is consensus that `log` shouldn't be a statement.
......@@ -212,7 +212,7 @@ do drop
else enum extern
false fn for
if impl
let log loop
let loop
match mod mut
priv pub pure
ref return
......@@ -805,21 +805,20 @@ Use declarations support a number of "convenience" notations:
An example of `use` declarations:
~~~~
use foo = core::info;
use core::float::sin;
use core::str::{slice, to_upper};
use core::option::Some;
fn main() {
// Equivalent to 'log(core::info, core::float::sin(1.0));'
log(foo, sin(1.0));
// Equivalent to 'info!(core::float::sin(1.0));'
info!(sin(1.0));
// Equivalent to 'log(core::info, core::option::Some(1.0));'
log(info, Some(1.0));
// Equivalent to 'info!(core::option::Some(1.0));'
info!(Some(1.0));
// Equivalent to 'log(core::info,
// core::str::to_upper(core::str::slice("foo", 0, 1)));'
log(info, to_upper(slice("foo", 0, 1)));
// Equivalent to
// 'info!(core::str::to_upper(core::str::slice("foo", 0, 1)));'
info!(to_upper(slice("foo", 0, 1)));
}
~~~~
......@@ -990,7 +989,7 @@ output slot type would normally be. For example:
~~~~
fn my_err(s: &str) -> ! {
log(info, s);
info!(s);
fail!();
}
~~~~
......@@ -2397,58 +2396,6 @@ fn max(a: int, b: int) -> int {
}
~~~~
### Log expressions
~~~~~~~~{.ebnf .gram}
log_expr : "log" '(' level ',' expr ')' ;
~~~~~~~~
Evaluating a `log` expression may, depending on runtime configuration, cause a
value to be appended to an internal diagnostic logging buffer provided by the
runtime or emitted to a system console. Log expressions are enabled or
disabled dynamically at run-time on a per-task and per-item basis. See
[logging system](#logging-system).
Each `log` expression must be provided with a *level* argument in
addition to the value to log. The logging level is a `u32` value, where
lower levels indicate more-urgent levels of logging. By default, the lowest
four logging levels (`1_u32 ... 4_u32`) are predefined as the constants
`error`, `warn`, `info` and `debug` in the `core` library.
Additionally, the macros `error!`, `warn!`, `info!` and `debug!` are defined
in the default syntax-extension namespace. These expand into calls to the
logging facility composed with calls to the `fmt!` string formatting
syntax-extension.
The following examples all produce the same output, logged at the `error`
logging level:
~~~~
# let filename = "bulbasaur";
// Full version, logging a value.
log(core::error, ~"file not found: " + filename);
// Log-level abbreviated, since core::* is used by default.
log(error, ~"file not found: " + filename);
// Formatting the message using a format-string and fmt!
log(error, fmt!("file not found: %s", filename));
// Using the error! macro, that expands to the previous call.
error!("file not found: %s", filename);
~~~~
A `log` expression is *not evaluated* when logging at the specified logging-level, module or task is disabled at runtime.
This makes inactive `log` expressions very cheap;
they should be used extensively in Rust code, as diagnostic aids,
as they add little overhead beyond a single integer-compare and branch at runtime.
Logging is presently implemented as a language built-in feature,
as it makes use of compiler-provided, per-module data tables and flags.
In the future, logging will move into a library, and will no longer be a core expression type.
It is therefore recommended to use the macro forms of logging (`error!`, `debug!`, etc.) to minimize disruption in code that uses logging.
# Type system
......@@ -3149,7 +3096,7 @@ communication facilities.
The runtime contains a system for directing [logging
expressions](#log-expressions) to a logging console and/or internal logging
buffers. Logging expressions can be enabled per module.
buffers. Logging can be enabled per module.
Logging output is enabled by setting the `RUST_LOG` environment
variable. `RUST_LOG` accepts a logging specification made up of a
......
......@@ -744,7 +744,7 @@ unit, `()`, as the empty tuple if you like).
~~~~
let mytup: (int, int, float) = (10, 20, 30.0);
match mytup {
(a, b, c) => log(info, a + b + (c as int))
(a, b, c) => info!(a + b + (c as int))
}
~~~~
......@@ -760,7 +760,7 @@ For example:
struct MyTup(int, int, float);
let mytup: MyTup = MyTup(10, 20, 30.0);
match mytup {
MyTup(a, b, c) => log(info, a + b + (c as int))
MyTup(a, b, c) => info!(a + b + (c as int))
}
~~~~
......
......@@ -46,6 +46,6 @@ pub fn path_div() -> ~str { ~":" }
pub fn path_div() -> ~str { ~";" }
pub fn logv(config: config, s: ~str) {
log(debug, s);
debug!("%s", s);
if config.verbose { io::println(s); }
}
......@@ -216,14 +216,17 @@ pub use clone::Clone;
* more-verbosity. Error is the bottom level, default logging level is
* warn-and-below.
*/
/// The error log level
#[cfg(stage0)]
pub const error : u32 = 1_u32;
/// The warning log level
#[cfg(stage0)]
pub const warn : u32 = 2_u32;
/// The info log level
#[cfg(stage0)]
pub const info : u32 = 3_u32;
/// The debug log level
#[cfg(stage0)]
pub const debug : u32 = 4_u32;
......@@ -251,9 +254,13 @@ pub mod rt;
// can be resolved within libcore.
#[doc(hidden)] // FIXME #3538
pub mod core {
#[cfg(stage0)]
pub const error : u32 = 1_u32;
#[cfg(stage0)]
pub const warn : u32 = 2_u32;
#[cfg(stage0)]
pub const info : u32 = 3_u32;
#[cfg(stage0)]
pub const debug : u32 = 4_u32;
pub use cmp;
......
......@@ -683,7 +683,7 @@ fn write(&self, v: &[const u8]) {
*self);
if nout != len as size_t {
error!("error writing buffer");
log(error, os::last_os_error());
error!("%s", os::last_os_error());
fail!();
}
}
......@@ -733,7 +733,7 @@ fn write(&self, v: &[const u8]) {
let nout = libc::write(*self, vb, len as size_t);
if nout < 0 as ssize_t {
error!("error writing buffer");
log(error, os::last_os_error());
error!("%s", os::last_os_error());
fail!();
}
count += nout as uint;
......@@ -1288,7 +1288,6 @@ pub fn obj_sync(o: FSyncable, opt_level: Option<Level>,
#[cfg(test)]
mod tests {
use debug;
use i32;
use io::{BytesWriter, SeekCur, SeekEnd, SeekSet};
use io;
......@@ -1301,10 +1300,10 @@ mod tests {
#[test]
fn test_simple() {
let tmpfile = &Path("tmp/lib-io-test-simple.tmp");
log(debug, tmpfile);
debug!(tmpfile);
let frood: ~str =
~"A hoopy frood who really knows where his towel is.";
log(debug, copy frood);
debug!(copy frood);
{
let out: io::Writer =
result::get(
......@@ -1313,7 +1312,7 @@ fn test_simple() {
}
let inp: io::Reader = result::get(&io::file_reader(tmpfile));
let frood2: ~str = inp.read_c_str();
log(debug, copy frood2);
debug!(copy frood2);
fail_unless!(frood == frood2);
}
......
......@@ -208,8 +208,8 @@ unsafe fn get_env_pairs() -> ~[~str] {
let mut result = ~[];
ptr::array_each(environ, |e| {
let env_pair = str::raw::from_c_str(e);
log(debug, fmt!("get_env_pairs: %s",
env_pair));
debug!("get_env_pairs: %s",
env_pair);
result.push(env_pair);
});
result
......@@ -219,9 +219,8 @@ fn env_convert(input: ~[~str]) -> ~[(~str, ~str)] {
let mut pairs = ~[];
for input.each |p| {
let vs = str::splitn_char(*p, '=', 1);
log(debug,
fmt!("splitting: len: %u",
vs.len()));
debug!("splitting: len: %u",
vs.len());
fail_unless!(vs.len() == 2);
pairs.push((copy vs[0], copy vs[1]));
}
......@@ -682,10 +681,10 @@ unsafe fn rust_list_dir_val(ptr: *dirent_t)
let input = p.to_str();
let mut strings = ~[];
let input_ptr = ::cast::transmute(&input[0]);
log(debug, "os::list_dir -- BEFORE OPENDIR");
debug!("os::list_dir -- BEFORE OPENDIR");
let dir_ptr = opendir(input_ptr);
if (dir_ptr as uint != 0) {
log(debug, "os::list_dir -- opendir() SUCCESS");
debug!("os::list_dir -- opendir() SUCCESS");
let mut entry_ptr = readdir(dir_ptr);
while (entry_ptr as uint != 0) {
strings.push(
......@@ -697,11 +696,11 @@ unsafe fn rust_list_dir_val(ptr: *dirent_t)
closedir(dir_ptr);
}
else {
log(debug, "os::list_dir -- opendir() FAILURE");
debug!("os::list_dir -- opendir() FAILURE");
}
log(debug,
fmt!("os::list_dir -- AFTER -- #: %?",
strings.len()));
debug!(
"os::list_dir -- AFTER -- #: %?",
strings.len());
strings
}
#[cfg(windows)]
......@@ -1258,7 +1257,6 @@ pub mod mips {
#[cfg(test)]
#[allow(non_implicitly_copyable_typarams)]
mod tests {
use debug;
use libc::{c_int, c_void, size_t};
use libc;
use option::{None, Option, Some};
......@@ -1274,7 +1272,7 @@ mod tests {
#[test]
pub fn last_os_error() {
log(debug, os::last_os_error());
debug!(os::last_os_error());
}
#[test]
......@@ -1320,7 +1318,7 @@ fn test_getenv_big() {
while i < 100 { s += ~"aaaaaaaaaa"; i += 1; }
let n = make_rand_name();
setenv(n, s);
log(debug, copy s);
debug!(copy s);
fail_unless!(getenv(n) == option::Some(s));
}
......@@ -1329,7 +1327,7 @@ fn test_self_exe_path() {
let path = os::self_exe_path();
fail_unless!(path.is_some());
let path = path.get();
log(debug, copy path);
debug!(copy path);
// Hard to test this function
fail_unless!(path.is_absolute);
......@@ -1342,7 +1340,7 @@ fn test_env_getenv() {
fail_unless!(vec::len(e) > 0u);
for vec::each(e) |p| {
let (n, v) = copy *p;
log(debug, copy n);
debug!(copy n);
let v2 = getenv(n);
// MingW seems to set some funky environment variables like
// "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned
......@@ -1367,10 +1365,10 @@ fn test_env_setenv() {
fn test() {
fail_unless!((!Path("test-path").is_absolute));
log(debug, ~"Current working directory: " + getcwd().to_str());
debug!(~"Current working directory: " + getcwd().to_str());
log(debug, make_absolute(&Path("test-path")));
log(debug, make_absolute(&Path("/usr/bin")));
debug!(make_absolute(&Path("test-path")));
debug!(make_absolute(&Path("/usr/bin")));
}
#[test]
......@@ -1433,7 +1431,7 @@ fn list_dir() {
fail_unless!((vec::len(dirs) > 0u));
for vec::each(dirs) |dir| {
log(debug, copy *dir);
debug!(copy *dir);
}
}
......
......@@ -82,18 +82,3 @@
pub use u8;
pub use uint;
pub use vec;
/*
* Export the log levels as global constants. Higher levels mean
* more-verbosity. Error is the bottom level, default logging level is
* warn-and-below.
*/
/// The error log level
pub const error : u32 = 1_u32;
/// The warning log level
pub const warn : u32 = 2_u32;
/// The info log level
pub const info : u32 = 3_u32;
/// The debug log level
pub const debug : u32 = 4_u32;
......@@ -19,7 +19,6 @@
#[cfg(test)] use vec;
#[cfg(test)] use str;
#[cfg(notest)] use cmp::{Eq, Ord};
use debug;
use uint;
pub mod libc_ {
......@@ -191,7 +190,7 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: int, count: uint) {
SAFETY NOTE: Pointer-arithmetic. Dragons be here.
*/
pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: &fn(*T)) {
log(debug, "array_each_with_len: before iterate");
debug!("array_each_with_len: before iterate");
if (arr as uint == 0) {
fail!(~"ptr::array_each_with_len failure: arr input is null pointer");
}
......@@ -201,7 +200,7 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: &fn(*T)) {
cb(*n);
true
});
log(debug, "array_each_with_len: after iterate");
debug!("array_each_with_len: after iterate");
}
/**
......@@ -218,8 +217,8 @@ pub unsafe fn array_each<T>(arr: **T, cb: &fn(*T)) {
fail!(~"ptr::array_each_with_len failure: arr input is null pointer");
}
let len = buf_len(arr);
log(debug, fmt!("array_each inferred len: %u",
len));
debug!("array_each inferred len: %u",
len);
array_each_with_len(arr, len, cb);
}
......@@ -434,7 +433,6 @@ pub fn test_is_null() {
#[cfg(test)]
pub mod ptr_tests {
use debug;
use ptr;
use str;
use libc;
......@@ -460,9 +458,9 @@ pub fn test_ptr_array_each_with_len() {
|e| {
let actual = str::raw::from_c_str(e);
let expected = copy expected_arr[ctr];
log(debug,
fmt!("test_ptr_array_each e: %s, a: %s",
expected, actual));
debug!(
"test_ptr_array_each e: %s, a: %s",
expected, actual);
fail_unless!(actual == expected);
ctr += 1;
iteration_count += 1;
......@@ -492,9 +490,9 @@ pub fn test_ptr_array_each() {
ptr::array_each(arr_ptr, |e| {
let actual = str::raw::from_c_str(e);
let expected = copy expected_arr[ctr];
log(debug,
fmt!("test_ptr_array_each e: %s, a: %s",
expected, actual));
debug!(
"test_ptr_array_each e: %s, a: %s",
expected, actual);
fail_unless!(actual == expected);
ctr += 1;
iteration_count += 1;
......
......@@ -494,7 +494,6 @@ pub fn random() -> uint {
#[cfg(test)]
pub mod tests {
use debug;
use option::{None, Option, Some};
use rand;
......@@ -563,7 +562,7 @@ pub fn gen_float() {
let r = rand::Rng();
let a = r.gen_float();
let b = r.gen_float();
log(debug, (a, b));
debug!((a, b));
}
#[test]
......@@ -576,9 +575,9 @@ pub fn gen_weighted_bool() {
#[test]
pub fn gen_str() {
let r = rand::Rng();
log(debug, r.gen_str(10u));
log(debug, r.gen_str(10u));
log(debug, r.gen_str(10u));
debug!(r.gen_str(10u));
debug!(r.gen_str(10u));
debug!(r.gen_str(10u));
fail_unless!(r.gen_str(0u).len() == 0u);
fail_unless!(r.gen_str(10u).len() == 10u);
fail_unless!(r.gen_str(16u).len() == 16u);
......
......@@ -458,7 +458,6 @@ fn WEXITSTATUS(status: i32) -> i32 {
#[cfg(test)]
mod tests {
use debug;
use option::{None, Some};
use os;
use run::{readclose, writeclose};
......@@ -494,8 +493,8 @@ pub fn test_pipes() {
readclose(pipe_err.in);
os::waitpid(pid);
log(debug, copy expected);
log(debug, copy actual);
debug!(copy expected);
debug!(copy actual);
fail_unless!((expected == actual));
}
......
......@@ -2437,7 +2437,6 @@ fn push_char(&mut self, c: char) {
mod tests {
use char;
use option::Some;
use debug;
use libc::c_char;
use libc;
use ptr;
......@@ -2523,7 +2522,7 @@ fn test_pop_char_fail() {
#[test]
fn test_split_char() {
fn t(s: &str, c: char, u: &[~str]) {
log(debug, ~"split_byte: " + s);
debug!(~"split_byte: " + s);
let v = split_char(s, c);
debug!("split_byte to: %?", v);
fail_unless!(vec::all2(v, u, |a,b| a == b));
......@@ -2552,7 +2551,7 @@ fn test_split_char_2() {
#[test]
fn test_splitn_char() {
fn t(s: &str, c: char, n: uint, u: &[~str]) {
log(debug, ~"splitn_byte: " + s);
debug!(~"splitn_byte: " + s);
let v = splitn_char(s, c, n);
debug!("split_byte to: %?", v);
debug!("comparing vs. %?", u);
......@@ -3192,8 +3191,8 @@ fn vec_str_conversions() {
while i < n1 {
let a: u8 = s1[i];
let b: u8 = s2[i];
log(debug, a);
log(debug, b);
debug!(a);
debug!(b);
fail_unless!((a == b));
i += 1u;
}
......
此差异已折叠。
......@@ -289,10 +289,10 @@ pub fn check_variants_T<T: Copy>(
if L < 100 {
do under(uint::min(L, 20)) |i| {
log(error, ~"Replacing... #" + uint::to_str(i));
error!("Replacing... #%?", uint::to_str(i));
let fname = str::from_slice(filename.to_str());
do under(uint::min(L, 30)) |j| {
log(error, ~"With... " + stringifier(@things[j], intr));
error!("With... %?", stringifier(@things[j], intr));
let crate2 = @replacer(crate, i, things[j], cx.mode);
// It would be best to test the *crate* for stability, but
// testing the string for stability is easier and ok for now.
......@@ -363,8 +363,8 @@ pub fn check_whole_compiler(code: ~str, suggested_filename_prefix: &Path,
removeDirIfExists(&suggested_filename_prefix.with_filetype("dSYM"));
}
failed(s) => {
log(error, ~"check_whole_compiler failure: " + s);
log(error, ~"Saved as: " + filename.to_str());
error!("check_whole_compiler failure: %?", s);
error!("Saved as: %?", filename.to_str());
}
}
}
......@@ -387,7 +387,7 @@ pub fn check_running(exe_filename: &Path) -> happiness {
~[exe_filename.to_str()]);
let comb = p.out + ~"\n" + p.err;
if str::len(comb) > 1u {
log(error, ~"comb comb comb: " + comb);
error!("comb comb comb: %?", comb);
}
if contains(comb, ~"Assertion failed:") {
......@@ -433,21 +433,21 @@ pub fn check_compiling(filename: &Path) -> happiness {
if contains(p.err, ~"error:") {
cleanly_rejected(~"rejected with span_error")
} else {
log(error, ~"Stderr: " + p.err);
error!("Stderr: %?", p.err);
failed(~"Unfamiliar error message")
}
} else if contains(p.out, ~"Assertion") && contains(p.out, ~"failed") {
log(error, ~"Stdout: " + p.out);
error!("Stdout: %?", p.out);
failed(~"Looks like an llvm assertion failure")
} else if contains(p.out, ~"internal compiler error unimplemented") {
known_bug(~"Something unimplemented")
} else if contains(p.out, ~"internal compiler error") {
log(error, ~"Stdout: " + p.out);
error!("Stdout: %?", p.out);
failed(~"internal compiler error")
} else {
log(error, p.status);
log(error, ~"!Stdout: " + p.out);
error!("%?", p.status);
error!("!Stdout: %?", p.out);
failed(~"What happened?")
}
}
......@@ -609,7 +609,7 @@ pub fn check_variants(files: &[Path], cx: Context) {
let file_str = file.to_str();
log(error, ~"check_variants: " + file_str);
error!("check_variants: %?", file_str);
let sess = parse::new_parse_sess(option::None);
let crate =
parse::parse_crate_from_source_str(
......
......@@ -758,7 +758,7 @@ fn unlib(config: @session::config, +stem: ~str) -> ~str {
/*bad*/copy *out_filename
};
log(debug, ~"output: " + output.to_str());
debug!("output: %s", output.to_str());
// The default library location, we need this to find the runtime.
// The location of crates will be determined as needed.
......
......@@ -803,12 +803,12 @@ pub fn invoke(bcx: block, llfn: ValueRef, +llargs: ~[ValueRef]) -> block {
let _icx = bcx.insn_ctxt("invoke_");
if bcx.unreachable { return bcx; }
if need_invoke(bcx) {
log(debug, ~"invoking");
debug!("invoking");
let normal_bcx = sub_block(bcx, ~"normal return");
Invoke(bcx, llfn, llargs, normal_bcx.llbb, get_landing_pad(bcx));
return normal_bcx;
} else {
log(debug, ~"calling");
debug!("calling");
Call(bcx, llfn, llargs);
return bcx;
}
......@@ -1487,7 +1487,7 @@ pub fn alloc_ty(bcx: block, t: ty::t) -> ValueRef {
let _icx = bcx.insn_ctxt("alloc_ty");
let ccx = bcx.ccx();
let llty = type_of::type_of(ccx, t);
if ty::type_has_params(t) { log(error, ty_to_str(ccx.tcx, t)); }
if ty::type_has_params(t) { error!("%s", ty_to_str(ccx.tcx, t)); }
fail_unless!(!ty::type_has_params(t));
let val = alloca(bcx, llty);
return val;
......
......@@ -848,7 +848,7 @@ pub fn add_span_comment(bcx: block, sp: span, text: &str) {
let ccx = bcx.ccx();
if !ccx.sess.no_asm_comments() {
let s = fmt!("%s (%s)", text, ccx.sess.codemap.span_to_str(sp));
log(debug, copy s);
debug!("%s", copy s);
add_comment(bcx, s);
}
}
......
......@@ -806,10 +806,10 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
let dbg_cx = (/*bad*/copy cx.dbg_cx).get();
debug!("~~");
log(debug, fcx.id);
debug!("%?", fcx.id);
let sp = fcx.span.get();
log(debug, cx.sess.codemap.span_to_str(sp));
debug!("%s", cx.sess.codemap.span_to_str(sp));
let (ident, ret_ty, id) = match cx.tcx.items.get(&fcx.id) {
ast_map::node_item(item, _) => {
......@@ -841,8 +841,8 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
sort of node")
};
log(debug, ident);
log(debug, id);
debug!("%?", ident);
debug!("%?", id);
let cache = get_cache(cx);
match cached_metadata::<@Metadata<SubProgramMetadata>>(
......
......@@ -708,7 +708,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info {
free_glue: None,
visit_glue: None
};
log(debug, ~"--- declare_tydesc " + ppaux::ty_to_str(ccx.tcx, t));
debug!("--- declare_tydesc %s", ppaux::ty_to_str(ccx.tcx, t));
return inf;
}
......
......@@ -128,7 +128,7 @@ struct Bored {
}
impl Drop for Bored {
fn finalize(&self) { log(error, self.bored); }
fn finalize(&self) { }
}
/**
......
......@@ -31,7 +31,7 @@ pub fn run_passes(
) -> doc::Doc {
let mut passno = 0;
do vec::foldl(doc, passes) |doc, pass| {
log(debug, fmt!("pass #%d", passno));
debug!("pass #%d", passno);
passno += 1;
do time(copy pass.name) {
(pass.f)(srv.clone(), copy doc)
......
......@@ -509,7 +509,7 @@ pub fn manually_share_arc() {
fail_unless!((*arc::get(&arc_v))[2] == 3);
log(info, arc_v);
info!(arc_v);
}
#[test]
......
......@@ -116,7 +116,6 @@ mod tests {
use super::*;
use core::cmp::Eq;
use core::kinds::{Durable, Copy};
use core::prelude::debug;
#[test]
fn test_simple() {
......@@ -128,21 +127,21 @@ fn test_simple() {
fail_unless!(d.len() == 3u);
d.add_back(137);
fail_unless!(d.len() == 4u);
log(debug, d.peek_front());
debug!(d.peek_front());
fail_unless!(*d.peek_front() == 42);
log(debug, d.peek_back());
debug!(d.peek_back());
fail_unless!(*d.peek_back() == 137);
let mut i: int = d.pop_front();
log(debug, i);
debug!(i);
fail_unless!(i == 42);
i = d.pop_back();
log(debug, i);
debug!(i);
fail_unless!(i == 137);
i = d.pop_back();
log(debug, i);
debug!(i);
fail_unless!(i == 137);
i = d.pop_back();
log(debug, i);
debug!(i);
fail_unless!(i == 17);
fail_unless!(d.len() == 0u);
d.add_back(3);
......@@ -153,10 +152,10 @@ fn test_simple() {
fail_unless!(d.len() == 3u);
d.add_front(1);
fail_unless!(d.len() == 4u);
log(debug, d.get(0));
log(debug, d.get(1));
log(debug, d.get(2));
log(debug, d.get(3));
debug!(d.get(0));
debug!(d.get(1));
debug!(d.get(2));
debug!(d.get(3));
fail_unless!(*d.get(0) == 1);
fail_unless!(*d.get(1) == 2);
fail_unless!(*d.get(2) == 3);
......
......@@ -881,7 +881,7 @@ pub fn test_optflag_long_arg() {
let rs = getopts(args, opts);
match rs {
Err(copy f) => {
log(error, fail_str(f));
error!(fail_str(f));
check_fail_type(f, UnexpectedArgument_);
}
_ => fail!()
......
......@@ -117,7 +117,7 @@ pub fn get_addr(node: &str, iotask: &iotask)
do str::as_buf(node) |node_ptr, len| {
let output_ch = output_ch.swap_unwrap();
unsafe {
log(debug, fmt!("slice len %?", len));
debug!("slice len %?", len);
let handle = create_uv_getaddrinfo_t();
let handle_ptr = ptr::addr_of(&handle);
let handle_data = GetAddrData {
......@@ -228,8 +228,8 @@ pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
let new_addr = uv_ip4_addr(str::from_slice(ip), 22);
let reformatted_name = uv_ip4_name(&new_addr);
log(debug, fmt!("try_parse_addr: input ip: %s reparsed ip: %s",
ip, reformatted_name));
debug!("try_parse_addr: input ip: %s reparsed ip: %s",
ip, reformatted_name);
let ref_ip_rep_result = parse_to_ipv4_rep(reformatted_name);
if result::is_err(&ref_ip_rep_result) {
let err_str = result::get_err(&ref_ip_rep_result);
......@@ -282,8 +282,8 @@ pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
// need to figure out how to establish a parse failure..
let new_addr = uv_ip6_addr(str::from_slice(ip), 22);
let reparsed_name = uv_ip6_name(&new_addr);
log(debug, fmt!("v6::try_parse_addr ip: '%s' reparsed '%s'",
ip, reparsed_name));
debug!("v6::try_parse_addr ip: '%s' reparsed '%s'",
ip, reparsed_name);
// '::' appears to be uv_ip6_name() returns for bogus
// parses..
if ip != &"::" && reparsed_name == ~"::" {
......@@ -303,14 +303,14 @@ struct GetAddrData {
extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
res: *addrinfo) {
unsafe {
log(debug, ~"in get_addr_cb");
debug!("in get_addr_cb");
let handle_data = get_data_for_req(handle) as
*GetAddrData;
let output_ch = (*handle_data).output_ch.clone();
if status == 0i32 {
if res != (ptr::null::<addrinfo>()) {
let mut out_vec = ~[];
log(debug, fmt!("initial addrinfo: %?", res));
debug!("initial addrinfo: %?", res);
let mut curr_addr = res;
loop {
let new_ip_addr = if ll::is_ipv4_addrinfo(curr_addr) {
......@@ -322,8 +322,8 @@ struct GetAddrData {
*ll::addrinfo_as_sockaddr_in6(curr_addr))))
}
else {
log(debug, ~"curr_addr is not of family AF_INET or "+
~"AF_INET6. Error.");
debug!("curr_addr is not of family AF_INET or \
AF_INET6. Error.");
output_ch.send(
result::Err(GetAddrUnknownError));
break;
......@@ -332,33 +332,33 @@ struct GetAddrData {
let next_addr = ll::get_next_addrinfo(curr_addr);
if next_addr == ptr::null::<addrinfo>() as *addrinfo {
log(debug, ~"null next_addr encountered. no mas");
debug!("null next_addr encountered. no mas");
break;
}
else {
curr_addr = next_addr;
log(debug, fmt!("next_addr addrinfo: %?", curr_addr));
debug!("next_addr addrinfo: %?", curr_addr);
}
}
log(debug, fmt!("successful process addrinfo result, len: %?",
vec::len(out_vec)));
debug!("successful process addrinfo result, len: %?",
vec::len(out_vec));
output_ch.send(result::Ok(out_vec));
}
else {
log(debug, ~"addrinfo pointer is NULL");
debug!("addrinfo pointer is NULL");
output_ch.send(
result::Err(GetAddrUnknownError));
}
}
else {
log(debug, ~"status != 0 error in get_addr_cb");
debug!("status != 0 error in get_addr_cb");
output_ch.send(
result::Err(GetAddrUnknownError));
}
if res != (ptr::null::<addrinfo>()) {
uv_freeaddrinfo(res);
}
log(debug, ~"leaving get_addr_cb");
debug!("leaving get_addr_cb");
}
}
......@@ -384,15 +384,15 @@ fn test_ip_ipv4_parse_and_format_ip() {
fn test_ip_ipv6_parse_and_format_ip() {
let localhost_str = ~"::1";
let format_result = format_addr(&v6::parse_addr(localhost_str));
log(debug, fmt!("results: expected: '%s' actual: '%s'",
localhost_str, format_result));
debug!("results: expected: '%s' actual: '%s'",
localhost_str, format_result);
fail_unless!(format_result == localhost_str);
}
#[test]
fn test_ip_ipv4_bad_parse() {
match v4::try_parse_addr(~"b4df00d") {
result::Err(ref err_info) => {
log(debug, fmt!("got error as expected %?", err_info));
debug!("got error as expected %?", err_info);
fail_unless!(true);
}
result::Ok(ref addr) => {
......@@ -405,7 +405,7 @@ fn test_ip_ipv4_bad_parse() {
fn test_ip_ipv6_bad_parse() {
match v6::try_parse_addr(~"::,~2234k;") {
result::Err(ref err_info) => {
log(debug, fmt!("got error as expected %?", err_info));
debug!("got error as expected %?", err_info);
fail_unless!(true);
}
result::Ok(ref addr) => {
......@@ -425,15 +425,15 @@ fn test_ip_get_addr() {
// note really sure how to realiably test/assert
// this.. mostly just wanting to see it work, atm.
let results = result::unwrap(ga_result);
log(debug, fmt!("test_get_addr: Number of results for %s: %?",
localhost_name, vec::len(results)));
debug!("test_get_addr: Number of results for %s: %?",
localhost_name, vec::len(results));
for vec::each(results) |r| {
let ipv_prefix = match *r {
Ipv4(_) => ~"IPv4",
Ipv6(_) => ~"IPv6"
};
log(debug, fmt!("test_get_addr: result %s: '%s'",
ipv_prefix, format_addr(r)));
debug!("test_get_addr: result %s: '%s'",
ipv_prefix, format_addr(r));
}
// at least one result.. this is going to vary from system
// to system, based on stuff like the contents of /etc/hosts
......
此差异已折叠。
......@@ -41,7 +41,7 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
let len = xs.len();
if len < min_granularity {
log(info, ~"small slice");
info!("small slice");
// This is a small vector, fall back on the normal map.
~[f()(0u, xs)]
}
......@@ -52,7 +52,7 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
let mut futures = ~[];
let mut base = 0u;
log(info, ~"spawning tasks");
info!("spawning tasks");
while base < len {
let end = uint::min(len, base + items_per_task);
do vec::as_imm_buf(xs) |p, _len| {
......@@ -63,11 +63,11 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
let len = end - base;
let slice = (ptr::offset(p, base),
len * sys::size_of::<A>());
log(info, fmt!("pre-slice: %?", (base, slice)));
info!("pre-slice: %?", (base, slice));
let slice : &[A] =
cast::reinterpret_cast(&slice);
log(info, fmt!("slice: %?",
(base, vec::len(slice), end - base)));
info!("slice: %?",
(base, vec::len(slice), end - base));
fail_unless!((vec::len(slice) == end - base));
f(base, slice)
}
......@@ -76,9 +76,9 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
};
base += items_per_task;
}
log(info, ~"tasks spawned");
info!("tasks spawned");
log(info, fmt!("num_tasks: %?", (num_tasks, futures.len())));
info!("num_tasks: %?", (num_tasks, futures.len()));
fail_unless!((num_tasks == futures.len()));
let r = do futures.map() |ys| {
......@@ -114,7 +114,7 @@ pub fn mapi<A:Copy + Owned,B:Copy + Owned>(
result
});
let r = vec::concat(slices);
log(info, (r.len(), xs.len()));
info!("%?", (r.len(), xs.len()));
fail_unless!((r.len() == xs.len()));
r
}
......
......@@ -721,7 +721,7 @@ pub fn check_sort(v1: &mut [int], v2: &mut [int]) {
quick_sort3::<int>(v1);
let mut i = 0;
while i < len {
log(debug, v2[i]);
debug!(v2[i]);
fail_unless!((v2[i] == v1[i]));
i += 1;
}
......@@ -768,7 +768,7 @@ pub fn check_sort(v1: &mut [int], v2: &mut [int]) {
quick_sort::<int>(v1, leual);
let mut i = 0u;
while i < len {
log(debug, v2[i]);
debug!(v2[i]);
fail_unless!((v2[i] == v1[i]));
i += 1;
}
......@@ -834,7 +834,7 @@ pub fn check_sort(v1: &[int], v2: &[int]) {
let v3 = merge_sort::<int>(v1, f);
let mut i = 0u;
while i < len {
log(debug, v3[i]);
debug!(v3[i]);
fail_unless!((v3[i] == v2[i]));
i += 1;
}
......@@ -918,7 +918,7 @@ fn check_sort(v1: &mut [int], v2: &mut [int]) {
tim_sort::<int>(v1);
let mut i = 0u;
while i < len {
log(debug, v2[i]);
debug!(v2[i]);
fail_unless!((v2[i] == v1[i]));
i += 1u;
}
......
......@@ -142,8 +142,8 @@ pub fn recv_timeout<T:Copy + Owned>(iotask: &IoTask,
extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t,
status: libc::c_int) {
unsafe {
log(debug,
fmt!("delayed_send_cb handle %? status %?", handle, status));
debug!(
"delayed_send_cb handle %? status %?", handle, status);
// Faking a borrowed pointer to our ~SharedChan
let timer_done_ch_ptr: &*c_void = &uv::ll::get_data_for_uv_handle(
handle);
......@@ -163,7 +163,7 @@ pub fn recv_timeout<T:Copy + Owned>(iotask: &IoTask,
extern fn delayed_send_close_cb(handle: *uv::ll::uv_timer_t) {
unsafe {
log(debug, fmt!("delayed_send_close_cb handle %?", handle));
debug!("delayed_send_close_cb handle %?", handle);
let timer_done_ch_ptr = uv::ll::get_data_for_uv_handle(handle);
let timer_done_ch = transmute::<*c_void, ~SharedChan<()>>(
timer_done_ch_ptr);
......
......@@ -136,26 +136,25 @@ mod test {
timer_ptr as *libc::c_void);
let exit_ch = transmute::<*c_void, ~Chan<bool>>(exit_ch_ptr);
exit_ch.send(true);
log(debug,
fmt!("EXIT_CH_PTR simple_timer_close_cb exit_ch_ptr: %?",
exit_ch_ptr));
debug!("EXIT_CH_PTR simple_timer_close_cb exit_ch_ptr: %?",
exit_ch_ptr);
}
}
extern fn simple_timer_cb(timer_ptr: *ll::uv_timer_t,
_status: libc::c_int) {
unsafe {
log(debug, ~"in simple timer cb");
debug!(~"in simple timer cb");
ll::timer_stop(timer_ptr);
let hl_loop = &get_gl();
do iotask::interact(hl_loop) |_loop_ptr| {
log(debug, ~"closing timer");
debug!(~"closing timer");
unsafe {
ll::close(timer_ptr, simple_timer_close_cb);
}
log(debug, ~"about to deref exit_ch_ptr");
log(debug, ~"after msg sent on deref'd exit_ch");
debug!(~"about to deref exit_ch_ptr");
debug!(~"after msg sent on deref'd exit_ch");
};
log(debug, ~"exiting simple timer cb");
debug!(~"exiting simple timer cb");
}
}
......@@ -163,13 +162,13 @@ fn impl_uv_hl_simple_timer(iotask: &IoTask) {
unsafe {
let (exit_po, exit_ch) = stream::<bool>();
let exit_ch_ptr: *libc::c_void = transmute(~exit_ch);
log(debug, fmt!("EXIT_CH_PTR newly created exit_ch_ptr: %?",
exit_ch_ptr));
debug!("EXIT_CH_PTR newly created exit_ch_ptr: %?",
exit_ch_ptr);
let timer_handle = ll::timer_t();
let timer_ptr = ptr::addr_of(&timer_handle);
do iotask::interact(iotask) |loop_ptr| {
unsafe {
log(debug, ~"user code inside interact loop!!!");
debug!(~"user code inside interact loop!!!");
let init_status = ll::timer_init(loop_ptr, timer_ptr);
if(init_status == 0i32) {
ll::set_data_for_uv_handle(
......@@ -188,7 +187,7 @@ fn impl_uv_hl_simple_timer(iotask: &IoTask) {
}
};
exit_po.recv();
log(debug,
debug!(
~"global_loop timer test: msg recv on exit_po, done..");
}
}
......@@ -225,7 +224,7 @@ fn test_stress_gl_uv_global_loop_high_level_global_timer() {
for iter::repeat(cycles) {
exit_po.recv();
};
log(debug, ~"test_stress_gl_uv_global_loop_high_level_global_timer"+
debug!(~"test_stress_gl_uv_global_loop_high_level_global_timer"+
~" exiting sucessfully!");
}
}
......@@ -132,10 +132,10 @@ fn run_loop(iotask_ch: &Chan<IoTask>) {
};
iotask_ch.send(iotask);
log(debug, ~"about to run uv loop");
debug!("about to run uv loop");
// enter the loop... this blocks until the loop is done..
ll::run(loop_ptr);
log(debug, ~"uv loop ended");
debug!("uv loop ended");
ll::loop_delete(loop_ptr);
}
}
......@@ -158,8 +158,8 @@ fn send_msg(iotask: &IoTask,
extern fn wake_up_cb(async_handle: *ll::uv_async_t,
status: int) {
log(debug, fmt!("wake_up_cb extern.. handle: %? status: %?",
async_handle, status));
debug!("wake_up_cb extern.. handle: %? status: %?",
async_handle, status);
unsafe {
let loop_ptr = ll::get_loop_for_uv_handle(async_handle);
......@@ -178,13 +178,13 @@ fn send_msg(iotask: &IoTask,
fn begin_teardown(data: *IoTaskLoopData) {
unsafe {
log(debug, ~"iotask begin_teardown() called, close async_handle");
debug!("iotask begin_teardown() called, close async_handle");
let async_handle = (*data).async_handle;
ll::close(async_handle as *c_void, tear_down_close_cb);
}
}
extern fn tear_down_walk_cb(handle: *libc::c_void, arg: *libc::c_void) {
log(debug, ~"IN TEARDOWN WALK CB");
debug!("IN TEARDOWN WALK CB");
// pretty much, if we still have an active handle and it is *not*
// the async handle that facilities global loop communication, we
// want to barf out and fail
......@@ -194,7 +194,7 @@ fn begin_teardown(data: *IoTaskLoopData) {
extern fn tear_down_close_cb(handle: *ll::uv_async_t) {
unsafe {
let loop_ptr = ll::get_loop_for_uv_handle(handle);
log(debug, ~"in tear_down_close_cb");
debug!("in tear_down_close_cb");
ll::walk(loop_ptr, tear_down_walk_cb, handle as *libc::c_void);
}
}
......@@ -202,7 +202,7 @@ fn begin_teardown(data: *IoTaskLoopData) {
#[cfg(test)]
extern fn async_close_cb(handle: *ll::uv_async_t) {
unsafe {
log(debug, fmt!("async_close_cb handle %?", handle));
debug!("async_close_cb handle %?", handle);
let exit_ch = &(*(ll::get_data_for_uv_handle(handle)
as *AhData)).exit_ch;
let exit_ch = exit_ch.clone();
......@@ -213,8 +213,7 @@ fn begin_teardown(data: *IoTaskLoopData) {
#[cfg(test)]
extern fn async_handle_cb(handle: *ll::uv_async_t, status: libc::c_int) {
unsafe {
log(debug,
fmt!("async_handle_cb handle %? status %?",handle,status));
debug!("async_handle_cb handle %? status %?",handle,status);
ll::close(handle, async_close_cb);
}
}
......@@ -269,15 +268,15 @@ unsafe fn spawn_test_loop(exit_ch: ~Chan<()>) -> IoTask {
#[cfg(test)]
extern fn lifetime_handle_close(handle: *libc::c_void) {
unsafe {
log(debug, fmt!("lifetime_handle_close ptr %?", handle));
debug!("lifetime_handle_close ptr %?", handle);
}
}
#[cfg(test)]
extern fn lifetime_async_callback(handle: *libc::c_void,
status: libc::c_int) {
log(debug, fmt!("lifetime_handle_close ptr %? status %?",
handle, status));
debug!("lifetime_handle_close ptr %? status %?",
handle, status);
}
#[test]
......@@ -311,9 +310,9 @@ fn test_uv_iotask_async() {
debug!("waiting");
work_exit_po.recv();
};
log(debug, ~"sending teardown_loop msg..");
debug!(~"sending teardown_loop msg..");
exit(iotask);
exit_po.recv();
log(debug, ~"after recv on exit_po.. exiting..");
debug!(~"after recv on exit_po.. exiting..");
}
}
......@@ -411,34 +411,34 @@ pub fn core_macros() -> ~str {
macro_rules! error (
($arg:expr) => (
log(::core::error, fmt!( \"%?\", $arg ))
__log(1u32, fmt!( \"%?\", $arg ))
);
($( $arg:expr ),+) => (
log(::core::error, fmt!( $($arg),+ ))
__log(1u32, fmt!( $($arg),+ ))
)
)
macro_rules! warn (
($arg:expr) => (
log(::core::warn, fmt!( \"%?\", $arg ))
__log(2u32, fmt!( \"%?\", $arg ))
);
($( $arg:expr ),+) => (
log(::core::warn, fmt!( $($arg),+ ))
__log(2u32, fmt!( $($arg),+ ))
)
)
macro_rules! info (
($arg:expr) => (
log(::core::info, fmt!( \"%?\", $arg ))
__log(3u32, fmt!( \"%?\", $arg ))
);
($( $arg:expr ),+) => (
log(::core::info, fmt!( $($arg),+ ))
__log(3u32, fmt!( $($arg),+ ))
)
)
macro_rules! debug (
($arg:expr) => (
log(::core::debug, fmt!( \"%?\", $arg ))
__log(4u32, fmt!( \"%?\", $arg ))
);
($( $arg:expr ),+) => (
log(::core::debug, fmt!( $($arg),+ ))
__log(4u32, fmt!( $($arg),+ ))
)
)
......
......@@ -37,8 +37,7 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree])
expr_to_str(cx, args[0],
~"first argument to fmt! must be a string literal.");
let fmtspan = args[0].span;
debug!("Format string:");
log(debug, fmt);
debug!("Format string: %s", fmt);
fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: &str) -> ! {
cx.span_fatal(sp, msg);
}
......@@ -223,7 +222,7 @@ fn is_signed_type(cnv: Conv) -> bool {
}
fn log_conv(c: Conv) {
match c.param {
Some(p) => { log(debug, ~"param: " + p.to_str()); }
Some(p) => { debug!("param: %s", p.to_str()); }
_ => debug!("param: none")
}
for c.flags.each |f| {
......@@ -236,18 +235,18 @@ fn log_conv(c: Conv) {
}
}
match c.width {
CountIs(i) => log(
debug, ~"width: count is " + i.to_str()),
CountIsParam(i) => log(
debug, ~"width: count is param " + i.to_str()),
CountIs(i) =>
debug!("width: count is %s", i.to_str()),
CountIsParam(i) =>
debug!("width: count is param %s", i.to_str()),
CountIsNextParam => debug!("width: count is next param"),
CountImplied => debug!("width: count is implied")
}
match c.precision {
CountIs(i) => log(
debug, ~"prec: count is " + i.to_str()),
CountIsParam(i) => log(
debug, ~"prec: count is param " + i.to_str()),
CountIs(i) =>
debug!("prec: count is %s", i.to_str()),
CountIsParam(i) =>
debug!("prec: count is param %s", i.to_str()),
CountIsNextParam => debug!("prec: count is next param"),
CountImplied => debug!("prec: count is implied")
}
......
......@@ -183,7 +183,7 @@ fn read_line_comments(rdr: @mut StringReader, code_to_the_left: bool,
let mut lines: ~[~str] = ~[];
while rdr.curr == '/' && nextch(rdr) == '/' {
let line = read_one_line_comment(rdr);
log(debug, line);
debug!("%s", line);
if is_doc_comment(line) { // doc-comments are not put in comments
break;
}
......@@ -221,7 +221,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
s1 = str::slice(s, col, len);
} else { s1 = ~""; }
} else { s1 = /*bad*/ copy s; }
log(debug, ~"pushing line: " + s1);
debug!("pushing line: %s", s1);
lines.push(s1);
}
......
......@@ -1184,7 +1184,7 @@ fn parse_bottom_expr(&self) -> @expr {
}
}
hi = self.span.hi;
} else if self.eat_keyword(&~"log") {
} else if self.eat_keyword(&~"__log") {
self.expect(&token::LPAREN);
let lvl = self.parse_expr();
self.expect(&token::COMMA);
......
......@@ -495,7 +495,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> {
~"else", ~"enum", ~"extern",
~"false", ~"fn", ~"for",
~"if", ~"impl",
~"let", ~"log", ~"loop",
~"let", ~"__log", ~"loop",
~"match", ~"mod", ~"mut",
~"once",
~"priv", ~"pub", ~"pure",
......
......@@ -472,7 +472,7 @@ fn print_str(&mut self, s: ~str) {
fn print(&mut self, x: token, L: int) {
debug!("print %s %d (remaining line space=%d)", tok_str(x), L,
self.space);
log(debug, buf_str(copy self.token,
debug!("%s", buf_str(copy self.token,
copy self.size,
self.left,
self.right,
......
......@@ -22,6 +22,6 @@ fn main() {
for uint::range(0u, n) |i| {
let x = uint::to_str(i);
log(debug, x);
debug!(x);
}
}
......@@ -181,7 +181,7 @@ fn is_gray(c: &color) -> bool {
let mut i = 0;
while vec::any(colors, is_gray) {
// Do the BFS.
log(info, fmt!("PBFS iteration %?", i));
info!("PBFS iteration %?", i);
i += 1;
colors = do colors.mapi() |i, c| {
let c : color = *c;
......@@ -257,7 +257,7 @@ fn is_gray_factory() -> ~fn(c: &color) -> bool {
let mut i = 0;
while par::any(colors, is_gray_factory) {
// Do the BFS.
log(info, fmt!("PBFS iteration %?", i));
info!("PBFS iteration %?", i);
i += 1;
let old_len = colors.len();
......@@ -320,7 +320,7 @@ fn validate(edges: ~[(node_id, node_id)],
// parent chains back to the root. While we do this, we also
// compute the levels for each node.
log(info, ~"Verifying tree structure...");
info!(~"Verifying tree structure...");
let mut status = true;
let level = do tree.map() |parent| {
......@@ -352,7 +352,7 @@ fn validate(edges: ~[(node_id, node_id)],
// 2. Each tree edge connects vertices whose BFS levels differ by
// exactly one.
log(info, ~"Verifying tree edges...");
info!(~"Verifying tree edges...");
let status = do tree.alli() |k, parent| {
if *parent != root && *parent != -1i64 {
......@@ -368,7 +368,7 @@ fn validate(edges: ~[(node_id, node_id)],
// 3. Every edge in the input list has vertices with levels that
// differ by at most one or that both are not in the BFS tree.
log(info, ~"Verifying graph edges...");
info!(~"Verifying graph edges...");
let status = do edges.all() |e| {
let (u, v) = *e;
......@@ -385,7 +385,7 @@ fn validate(edges: ~[(node_id, node_id)],
// 5. A node and its parent are joined by an edge of the original
// graph.
log(info, ~"Verifying tree and graph edges...");
info!(~"Verifying tree and graph edges...");
let status = do par::alli(tree) {
let edges = copy edges;
......
......@@ -16,6 +16,6 @@
fn main() {
match true { false => { my_fail(); } true => { } }
log(debug, x); //~ ERROR unresolved name: `x`.
debug!(x); //~ ERROR unresolved name: `x`.
let x: int;
}
......@@ -11,6 +11,6 @@
// Check that bogus field access is non-fatal
fn main() {
let x = 0;
log(debug, x.foo); //~ ERROR attempted access of field
log(debug, x.bar); //~ ERROR attempted access of field
debug!(x.foo); //~ ERROR attempted access of field
debug!(x.bar); //~ ERROR attempted access of field
}
......@@ -22,11 +22,11 @@ fn main() {
let a: clam = clam{x: @1, y: @2};
let b: clam = clam{x: @10, y: @20};
let z: int = a.x + b.y;
log(debug, z);
debug!(z);
fail_unless!((z == 21));
let forty: fish = fish{a: @40};
let two: fish = fish{a: @2};
let answer: int = forty.a + two.a;
log(debug, answer);
debug!(answer);
fail_unless!((answer == 42));
}
......@@ -11,4 +11,4 @@
// error-pattern:expected `~str` but found `int`
const i: str = 10i;
fn main() { log(debug, i); }
fn main() { debug!(i); }
......@@ -18,6 +18,6 @@ fn compute1() -> float {
fn main() {
let x = compute1();
log(debug, x);
debug!(x);
fail_unless!((x == -4f));
}
......@@ -21,6 +21,6 @@ fn fn_id(+f: extern fn()) -> extern fn() { return f }
fn main() {
let i = 8;
let f = coerce(|| log(error, i) );
let f = coerce(|| error!(i) );
f();
}
......@@ -12,5 +12,5 @@ fn main() {
let x: int = 3;
let y: &mut int = &mut x; //~ ERROR illegal borrow
*y = 5;
log (debug, *y);
debug!(*y);
}
......@@ -26,5 +26,5 @@ fn main() {
let x = foo(10);
let _y = copy x;
//~^ ERROR copying a value of non-copyable type `foo`
log(error, x);
error!(x);
}
......@@ -12,7 +12,7 @@
// error-pattern: dead
fn f(caller: str) { log(debug, caller); }
fn f(caller: str) { debug!(caller); }
fn main() { return f("main"); debug!("Paul is dead"); }
......@@ -12,5 +12,5 @@
fn main() {
let a = if true { true };
log(debug, a);
debug!(a);
}
......@@ -10,5 +10,5 @@
fn main() {
let z = ();
log(debug, z[0]); //~ ERROR cannot index a value of type `()`
debug!(z[0]); //~ ERROR cannot index a value of type `()`
}
......@@ -9,5 +9,5 @@
// except according to those terms.
fn main() {
log(error, x); //~ ERROR unresolved name: `x`.
error!(x); //~ ERROR unresolved name: `x`.
}
......@@ -10,7 +10,7 @@
fn main() {
for vec::each(fail!()) |i| {
log (debug, i * 2);
debug!(i * 2);
//~^ ERROR the type of this value must be known
};
}
......@@ -15,5 +15,5 @@ struct cat {
fn main() {
let kitty : cat = cat { x: () };
log (error, *kitty);
error!(*kitty);
}
......@@ -15,5 +15,5 @@ struct cat {
fn main() {
let nyan = cat { foo: () };
log (error, *nyan);
error!(*nyan);
}
......@@ -11,6 +11,6 @@
enum test { thing = 3u } //~ ERROR mismatched types
//~^ ERROR expected signed integer constant
fn main() {
log(error, thing as int);
error!(thing as int);
fail_unless!((thing as int == 3));
}
......@@ -19,13 +19,13 @@ fn main()
{
let _z = match g(1, 2) {
g(x, x) => { log(debug, x + x); }
g(x, x) => { debug!(x + x); }
//~^ ERROR Identifier x is bound more than once in the same pattern
};
let _z = match i(l(1, 2), m(3, 4)) {
i(l(x, _), m(_, x)) //~ ERROR Identifier x is bound more than once in the same pattern
=> { log(error, x + x); }
=> { error!(x + x); }
};
let _z = match (1, 2) {
......
......@@ -13,5 +13,5 @@ fn main() {
const y: int = foo + 1; //~ ERROR: attempt to use a non-constant value in a constant
log(error, y);
error!(y);
}
......@@ -15,5 +15,5 @@ enum Stuff {
Bar = foo //~ ERROR attempt to use a non-constant value in a constant
}
log(error, Bar);
error!(Bar);
}
......@@ -16,10 +16,10 @@
fn main() {
let i = 0;
let ctr: @fn() -> int = || { f2(|| i = i + 1 ); i };
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, i);
error!(ctr());
error!(ctr());
error!(ctr());
error!(ctr());
error!(ctr());
error!(i);
}
......@@ -13,10 +13,10 @@
fn main() {
let i = 0;
let ctr: @fn() -> int = || { i = i + 1; i };
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, ctr());
log(error, i);
error!(ctr());
error!(ctr());
error!(ctr());
error!(ctr());
error!(ctr());
error!(i);
}
......@@ -11,6 +11,6 @@
fn main() {
let i: int;
log(debug, false && { i = 5; true });
log(debug, i); //~ ERROR use of possibly uninitialized variable: `i`
debug!(false && { i = 5; true });
debug!(i); //~ ERROR use of possibly uninitialized variable: `i`
}
......@@ -12,6 +12,6 @@
// Tests that a function with a ! annotation always actually fails
// error-pattern: some control paths may return
fn bad_bang(i: uint) -> ! { log(debug, 3); }
fn bad_bang(i: uint) -> ! { debug!(3); }
fn main() { bad_bang(5u); }
......@@ -12,6 +12,6 @@
fn main() {
let x: int;
force(|| {
log(debug, x); //~ ERROR capture of possibly uninitialized variable: `x`
debug!(x); //~ ERROR capture of possibly uninitialized variable: `x`
});
}
......@@ -16,9 +16,9 @@ fn foo() -> int {
x = 0; //~ WARNING unreachable statement
}
log(debug, x); //~ ERROR use of possibly uninitialized variable: `x`
debug!(x); //~ ERROR use of possibly uninitialized variable: `x`
return 17;
}
fn main() { log(debug, foo()); }
fn main() { debug!(foo()); }
......@@ -16,9 +16,9 @@ fn foo() -> int {
x = 0; //~ WARNING unreachable statement
}
log(debug, x); //~ ERROR use of possibly uninitialized variable: `x`
debug!(x); //~ ERROR use of possibly uninitialized variable: `x`
return 17;
}
fn main() { log(debug, foo()); }
fn main() { debug!(foo()); }
......@@ -9,4 +9,4 @@
// except according to those terms.
fn force(f: &fn() -> int) -> int { f() }
fn main() { log(debug, force(|| {})); } //~ ERROR mismatched types
fn main() { debug!(force(|| {})); } //~ ERROR mismatched types
......@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(x: int) { log(debug, x); }
fn foo(x: int) { debug!(x); }
fn main() {
let x: int; if 1 > 2 { x = 10; }
......
......@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(x: int) { log(debug, x); }
fn foo(x: int) { debug!(x); }
fn main() {
let x: int;
......
......@@ -13,5 +13,5 @@ fn main() {
let i: int;
i //~ ERROR use of possibly uninitialized variable: `i`
};
log(error, f());
error!(f());
}
......@@ -12,7 +12,7 @@ fn main() {
let y: ~int = ~42;
let mut x: ~int;
loop {
log(debug, y);
debug!(y);
loop {
loop {
loop {
......
......@@ -13,7 +13,7 @@ fn main() {
let y: ~int = ~42;
let mut x: ~int;
loop {
log(debug, y);
debug!(y);
// tjc: not sure why it prints the same error twice
while true { while true { while true { x = y; copy x; } } }
//~^ ERROR use of moved value: `y`
......
......@@ -11,6 +11,6 @@
fn main() {
let i: int;
log(debug, false || { i = 5; true });
log(debug, i); //~ ERROR use of possibly uninitialized variable: `i`
debug!(false || { i = 5; true });
debug!(i); //~ ERROR use of possibly uninitialized variable: `i`
}
......@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn foo(x: int) { log(debug, x); }
fn foo(x: int) { debug!(x); }
fn main() {
let x: int;
......
......@@ -11,6 +11,6 @@
fn main() {
let x = ~5;
let y = x;
log(debug, *x); //~ ERROR use of moved value: `x`
debug!(*x); //~ ERROR use of moved value: `x`
copy y;
}
......@@ -9,8 +9,8 @@
// except according to those terms.
fn send<T:Owned>(ch: _chan<T>, -data: T) {
log(debug, ch);
log(debug, data);
debug!(ch);
debug!(data);
fail!();
}
......@@ -20,7 +20,7 @@ fn send<T:Owned>(ch: _chan<T>, -data: T) {
// message after the send deinitializes it
fn test00_start(ch: _chan<~int>, message: ~int, _count: ~int) {
send(ch, message);
log(debug, message); //~ ERROR use of moved value: `message`
debug!(message); //~ ERROR use of moved value: `message`
}
fn main() { fail!(); }
......@@ -24,5 +24,5 @@ fn main() {
fail_unless!((*arc::get(&arc_v))[2] == 3);
log(info, arc_v);
info!(arc_v);
}
......@@ -22,5 +22,5 @@ fn main() {
fail_unless!((*arc::get(&arc_v))[2] == 3); //~ ERROR use of moved value: `arc_v`
log(info, arc_v);
info!(arc_v);
}
......@@ -31,6 +31,6 @@ fn foo(x: Port<()>) -> foo {
do task::spawn {
let y = x.take(); //~ ERROR value has non-owned type
log(error, y);
error!(y);
}
}
......@@ -39,5 +39,5 @@ fn foo(i:int) -> foo {
fn main() {
let x = foo(10);
let _y = copy x; //~ ERROR copying a value of non-copyable type
log(error, x);
error!(x);
}
......@@ -15,5 +15,5 @@ struct foo {
}
fn main() {
log(debug, foo{ x: 1 } as int);
debug!(foo{ x: 1 } as int);
}
......@@ -10,4 +10,4 @@
// error-pattern:literal out of range
fn main() { log(debug, 300u8); }
fn main() { debug!(300u8); }
......@@ -18,7 +18,7 @@ enum bar { t1((), Option<~[int]>), t2, }
fn foo(t: bar) {
match t {
t1(_, Some::<int>(x)) => {
log(debug, x);
debug!(x);
}
_ => { fail!(); }
}
......
......@@ -31,7 +31,7 @@ struct A { y: r }
// Can't do this copy
let x = ~~~A {y: r(i)};
let _z = copy x; //~ ERROR copying a value of non-copyable type
log(debug, x);
debug!(x);
}
log(error, *i);
error!(*i);
}
......@@ -14,5 +14,5 @@ fn test(f: @fn(uint) -> uint) -> uint {
fn main() {
let f: ~fn(x: uint) -> uint = |x| 4u;
log(debug, test(f)); //~ ERROR expected @ closure, found ~ closure
debug!(test(f)); //~ ERROR expected @ closure, found ~ closure
}
......@@ -19,5 +19,5 @@ fn finalize(&self) {}
fn main() {
let i = ~r { b: true };
let _j = copy i; //~ ERROR copying a value of non-copyable type
log(debug, i);
debug!(i);
}
......@@ -29,6 +29,6 @@ fn main() {
f(copy r1, copy r2);
//~^ ERROR copying a value of non-copyable type
//~^^ ERROR copying a value of non-copyable type
log(debug, (r2, *i1));
log(debug, (r1, *i2));
debug!((r2, *i1));
debug!((r1, *i2));
}
......@@ -12,5 +12,5 @@
fn main() {
loop{}
// red herring to make sure compilation fails
log(error, 42 == 'c');
error!(42 == 'c');
}
......@@ -11,5 +11,5 @@
// error-pattern:unsupported cast
fn main() {
log(debug, 1.0 as *libc::FILE); // Can't cast float to foreign.
debug!(1.0 as *libc::FILE); // Can't cast float to foreign.
}
......@@ -13,7 +13,7 @@
fn f() {
let v = ~[1i];
log(debug, v.some_field_name); //type error
debug!(v.some_field_name); //type error
}
fn main() { }
......@@ -25,5 +25,5 @@ fn main() {
let i = ~[r(0)];
let j = ~[r(1)];
let k = i + j;
log(debug, j);
debug!(j);
}
......@@ -17,4 +17,4 @@ fn cmp() -> int {
}
}
fn main() { log(error, cmp()); }
fn main() { error!(cmp()); }
......@@ -9,5 +9,5 @@
// except according to those terms.
// error-pattern:quux
fn my_err(s: ~str) -> ! { log(error, s); fail!(~"quux"); }
fn my_err(s: ~str) -> ! { error!(s); fail!(~"quux"); }
fn main() { 3u == my_err(~"bye"); }
......@@ -9,5 +9,5 @@
// except according to those terms.
// error-pattern:quux
fn my_err(s: ~str) -> ! { log(error, s); fail!(~"quux"); }
fn my_err(s: ~str) -> ! { error!(s); fail!(~"quux"); }
fn main() { 3u == my_err(~"bye"); }
......@@ -9,6 +9,6 @@
// except according to those terms.
// error-pattern:woe
fn f(a: int) { log(debug, a); }
fn f(a: int) { debug!(a); }
fn main() { f(fail!(~"woe")); }
......@@ -17,7 +17,7 @@
fn foo(x: uint) {
if even(x) {
log(debug, x);
debug!(x);
} else {
fail!(~"Number is odd");
}
......
......@@ -9,5 +9,5 @@
// except according to those terms.
// error-pattern:quux
fn my_err(s: ~str) -> ! { log(error, s); fail!(~"quux"); }
fn my_err(s: ~str) -> ! { error!(s); fail!(~"quux"); }
fn main() { if my_err(~"bye") { } }
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern:roflcopter
fn main() {
log (fail!(~"roflcopter"), 2);
}
......@@ -10,5 +10,5 @@
// error-pattern:get called on error result: ~"kitty"
fn main() {
log(error, result::get(&result::Err::<int,~str>(~"kitty")));
error!(result::get(&result::Err::<int,~str>(~"kitty")));
}
......@@ -11,7 +11,7 @@
// error-pattern:whatever
fn main() {
log(error, ~"whatever");
error!(~"whatever");
// Setting the exit status only works when the scheduler terminates
// normally. In this case we're going to fail, so instead of of
// returning 50 the process will return the typical rt failure code.
......
......@@ -30,7 +30,7 @@ fn r(x:int) -> r {
}
fn main() {
log(error, ~"whatever");
error!(~"whatever");
do task::spawn {
let i = r(5);
};
......
......@@ -11,7 +11,7 @@
// error-pattern:whatever
fn main() {
log(error, ~"whatever");
error!(~"whatever");
// 101 is the code the runtime uses on task failure and the value
// compiletest expects run-fail tests to return.
os::set_exit_status(101);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册