Skip to content

Logging fixes #8250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/libstd/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ pub fn log_type<T>(level: u32, object: &T) {
fn newsched_log_str(msg: ~str) {
use rt::task::Task;
use rt::local::Local;
use str::StrSlice;
use container::Container;

// Truncate the string
let buf_bytes = 256;
let msg = if msg.len() > buf_bytes {
msg.slice(0, buf_bytes) + "[...]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this make a string of length 257 into one of length 261? (expected behaviour?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it. I don't think it's a problem though. The goal is only to avoid spewing endless garbage - it doesn't need to be precise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On further consideration though, this is probably only appropriate behavior for the console logger, so likely belongs somewhere else. In theory logging can go to arbitrary sinks. Can be fixed in the future. Logging is going to be completely overhauled eventually anyway.

} else {
msg
};

unsafe {
match Local::try_unsafe_borrow::<Task>() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/assert-macro-explicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'assertion failed: false'
// error-pattern:failed at 'assertion failed: false'

fn main() {
assert!(false);
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/assert-macro-fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'test-assert-fmt 42 rust'
// error-pattern:failed at 'test-assert-fmt 42 rust'

fn main() {
assert!(false, "test-assert-fmt %d %s", 42, "rust");
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/assert-macro-owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'test-assert-owned'
// error-pattern:failed at 'test-assert-owned'

fn main() {
assert!(false, ~"test-assert-owned");
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/assert-macro-static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'test-assert-static'
// error-pattern:failed at 'test-assert-static'

fn main() {
assert!(false, "test-assert-static");
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/fail-macro-explicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'explicit failure'
// error-pattern:failed at 'explicit failure'

fn main() {
fail!();
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/fail-macro-fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'test-fail-fmt 42 rust'
// error-pattern:failed at 'test-fail-fmt 42 rust'

fn main() {
fail!("test-fail-fmt %d %s", 42, "rust");
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/fail-macro-owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'test-fail-owned'
// error-pattern:failed at 'test-fail-owned'

fn main() {
fail!("test-fail-owned");
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-fail/fail-macro-static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// error-pattern:task failed at 'test-fail-static'
// error-pattern:failed at 'test-fail-static'

fn main() {
fail!("test-fail-static");
Expand Down