Skip to content
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

Log functions truncate long strings #2459

Closed
jesse99 opened this issue May 28, 2012 · 2 comments
Closed

Log functions truncate long strings #2459

jesse99 opened this issue May 28, 2012 · 2 comments

Comments

@jesse99
Copy link
Contributor

jesse99 commented May 28, 2012

This is arguably a Good Thing, but there needs to be an indication that the string has been truncated. For example, appending an ellipsis or "...truncated" or something.

@jesse99
Copy link
Contributor Author

jesse99 commented May 28, 2012

Here's a repro. Unfortunately it's not much of a unit test atm, but if you run it you'll see that the last line ends with "hello world hel" which is bad.

// rustc --test long_strings.rs && ./long_strings
use std;

//#[test]
fn short()
{
    let text = "hello world";
    io::println(text);                        // hello world
    io::println(#fmt["%s", text]);        // hello world
    io::println(#fmt["%?", text]);        // "hello world"
    #error["%?", text];                    // rust: "\"hello world\""
}

#[test]
fn long()
{
    let mut text = "";
    iter::repeat(175u)
    {||
        text += " hello world";
    };
    io::println("1");
    io::println(text);    

    io::println("2");
    io::println(#fmt["%s", text]);

    io::println("3");
    io::println(#fmt["%?", text]);

    io::println("4");
    #error["%?", text];                    // all of the log macros are truncated
}

@brson
Copy link
Contributor

brson commented Jun 3, 2012

Fixed by @arkaitzj in 9a2b240. Test in 802a8c0.

@brson brson closed this as completed Jun 3, 2012
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
split cargo-miri into multiple files

also greatly extend the 'who calls who' comment
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants