summary refs log tree commit diff
path: root/src/libstd/rt/logging.rs
AgeCommit message (Collapse)AuthorLines
2014-01-07Fixup the rest of the tests in the compilerAlex Crichton-1/+0
2014-01-07std: Fill in all missing importsAlex Crichton-1/+4
Fallout from the previous commits
2014-01-06Support arbitrary stdout/stderr/logger handlesAlex Crichton-26/+0
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2013-12-31std: print RUST_LOG=::help in sorted order.Huon Wilson-2/+9
Fixes #8949.
2013-11-29Removed useless cmp::{min, max} reexports from the integer modulesMarvin Löbel-2/+1
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-5/+3
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-2/+2
2013-11-11Move std::rt::io to std::ioAlex Crichton-3/+3
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-1/+0
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
2013-11-10Clean up the remaining chunks of uvAlex Crichton-7/+5
2013-10-25Cache and buffer stdout per-task for printingAlex Crichton-2/+4
Almost all languages provide some form of buffering of the stdout stream, and this commit adds this feature for rust. A handle to stdout is lazily initialized in the Task structure as a buffered owned Writer trait object. The buffer behavior depends on where stdout is directed to. Like C, this line-buffers the stream when the output goes to a terminal (flushes on newlines), and also like C this uses a fixed-size buffer when output is not directed at a terminal. We may decide the fixed-size buffering is overkill, but it certainly does reduce write syscall counts when piping output elsewhere. This is a *huge* benefit to any code using logging macros or the printing macros. Formatting emits calls to `write` very frequently, and to have each of them backed by a write syscall was very expensive. In a local benchmark of printing 10000 lines of "what" to stdout, I got the following timings: when | terminal | redirected ---------------------------------- before | 0.575s | 0.525s after | 0.197s | 0.013s C | 0.019s | 0.004s I can also confirm that we're buffering the output appropriately in both situtations. We're still far slower than C, but I believe much of that has to do with the "homing" that all tasks due, we're still performing an order of magnitude more write syscalls than C does.
2013-10-24Move as much I/O as possible off of native::ioAlex Crichton-5/+15
When uv's TTY I/O is used for the stdio streams, the file descriptors are put into a non-blocking mode. This means that other concurrent writes to the same stream can fail with EAGAIN or EWOULDBLOCK. By all I/O to event-loop I/O, we avoid this error. There is one location which cannot move, which is the runtime's dumb_println function. This was implemented to handle the EAGAIN and EWOULDBLOCK errors and simply retry again and again.
2013-10-10Migrate users of io::fd_t to io::native::file::fd_tAlex Crichton-32/+17
2013-10-09auto merge of #9664 : alexcrichton/rust/logging, r=huonwbors-19/+2
This makes some headway on #3309, see commits for details.
2013-10-06get_crate_map returns an OptionFlorian Hahn-8/+18
2013-10-05Use &'self str instead of raw char pointer in ModEntryFlorian Hahn-67/+45
2013-10-05Use slice representation for module entries in CrateMapFlorian Hahn-7/+5
Relaxe lifetime of CrateMap as well.
2013-10-05Use slice representation for child crate mapsFlorian Hahn-10/+9
2013-10-03Document logging and remove old functionsAlex Crichton-19/+2
This adds a large doc-block to the top of the std::logging module explaining how to use it. This is mostly just making sure that all the information in the manual's section about logging is also here (in case someone decides to look into this module first). This also removes the old console_{on,off} methods. As far as I can tell, the functions were only used by the compiler, and there's no reason for them to be used because they're all turned off by default anyway (maybe they were turned on by default at some point...) I believe that this is the final nail in the coffin and closes #5021
2013-10-01Migrate users of 'loop' to 'continue'Alex Crichton-2/+2
Closes #9467
2013-09-30std: Remove usage of fmt!Alex Crichton-8/+10
2013-09-29Put a newline after each logging messageAlex Crichton-1/+1
2013-09-26std and rustc: Convert users of c_str to use .with_c_strErick Tryzelaar-6/+6
2013-09-25Refactor the logging system for fewer allocationsAlex Crichton-31/+22
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.
2013-09-23Register new snapshotsAlex Crichton-17/+1
2013-09-18librustc/libstd: No longer pass crate_map to start.Luqman Aden-0/+18
2013-09-16Add an SendStr typeMarvin Löbel-10/+5
A SendStr is a string that can hold either a ~str or a &'static str. This can be useful as an optimization when an allocation is sometimes needed but the common case is statically known. Possible use cases include Maps with both static and owned keys, or propagating error messages across task boundaries. SendStr implements most basic traits in a way that hides the fact that it is an enum; in particular things like order and equality are only determined by the content of the wrapped strings. Replaced std::rt:logging::SendableString with SendStr Added tests for using an SendStr as key in Hash- and Treemaps
2013-09-15Remove {uint,int,u64,i64,...}::from_str,from_str_radixblake2-ppc-1/+2
Remove these in favor of the two traits themselves and the wrapper function std::from_str::from_str. Add the function std::num::from_str_radix in the corresponding role for the FromStrRadix trait.
2013-09-14std::logging: Use a more specific enum than Eitherblake2-ppc-11/+13
2013-09-13Convert rust_crate_map.cpp to RustFlorian Hahn-54/+10
Conflicts: src/libstd/rt/logging.rs
2013-09-07Handle global log levels (fixes #6033)novalis-36/+100
2013-09-06Fix #6031. Allow symbolic log levels, not just numbers.novalis-18/+53
2013-09-04Convert rust_log.cpp to Rust, closes #8703Florian Hahn-15/+248
2013-08-19Rangechange the log message truncation limit.Michael Sullivan-1/+1
2013-08-19Add externfn macro and correctly label fixed_stack_segmentsNiko Matsakis-0/+6
2013-08-15Add ToCStr method .with_c_str()Kevin Ballard-1/+1
.with_c_str() is a replacement for the old .as_c_str(), to avoid unnecessary boilerplate. Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-06Merge commit 'd89ff7eef969aee6b493bc846b64d68358fafbcd' into ↵Erick Tryzelaar-4/+17
remove-str-trailing-nulls
2013-08-04std: Fix newsched logging truncationBrian Anderson-4/+17
The truncation needs to be done in the console logger in order to catch all the logging output, and because truncation only matters when outputting to the console.
2013-08-04std: replace str::as_c_str with std::c_strErick Tryzelaar-2/+2
2013-07-23std: move StrUtil::as_c_str into StrSliceErick Tryzelaar-5/+3
2013-06-21std: Make console log off/on controls work with newschedBrian Anderson-4/+16
2013-05-22libstd: Fix merge fallout.Patrick Walton-0/+68