about summary refs log tree commit diff
path: root/src/libstd/logging.rs
AgeCommit message (Collapse)AuthorLines
2014-02-14Fix all code examplesAlex Crichton-2/+2
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-3/+3
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-03std: Remove io::io_errorAlex Crichton-2/+9
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-01-17Tweak the interface of std::ioAlex Crichton-1/+1
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)
2014-01-06Support arbitrary stdout/stderr/logger handlesAlex Crichton-6/+52
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-27std: uniform modules titles for docLuca Bruno-1/+1
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-24std: Make logging safely implementedAlex Crichton-21/+11
This commit fixes the logging function to be safely implemented, as well as forcibly requiring a task to be present to use logging macros. This is safely implemented by transferring ownership of the logger from the task to the local stack frame in order to perform the print. This means that if a logger does more logging while logging a new one will be initialized and then will get overwritten once the initial logging function returns. Without a scheme such as this, it is possible to unsafely alias two loggers by logging twice (unsafely borrows from the task twice).
2013-12-23Fixing more doc testsAlex Crichton-1/+1
2013-12-23std: Fix all code examplesAlex Crichton-1/+1
2013-12-02Add a macro to check if logging at a given label is enabledPhilipp Brüschweiler-5/+20
This is useful when the information that is needed to do useful logging is expensive to produce.
2013-11-28Fix initial debug statements printing twiceAlex Crichton-5/+7
It may mislead you into thinking tasks are spawning twice, when in fact they are not.
2013-11-24Cache a task's stderr loggerAlex Crichton-1/+5
This is both useful for performance (otherwise logging is unbuffered), but also useful for correctness. Because when a task is destroyed we can't block the task waiting for the logger to close, loggers are opened with a 'CloseAsynchronously' specification. This causes libuv do defer the call to close() until the next turn of the event loop. If you spin in a tight loop around printing, you never yield control back to the libuv event loop, meaning that you simply enqueue a large number of close requests but nothing is actually closed. This queue ends up never getting closed, meaning that if you keep trying to create handles one will eventually fail, which the runtime will attempt to print the failure, causing mass destruction. Caching will provide better performance as well as prevent creation of too many handles. Closes #10626
2013-11-10Clean up the remaining chunks of uvAlex Crichton-7/+9
2013-10-24Move as much I/O as possible off of native::ioAlex Crichton-1/+1
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-03Document logging and remove old functionsAlex Crichton-27/+88
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-09-27Register new snapshotsAlex Crichton-9/+0
2013-09-25Refactor the logging system for fewer allocationsAlex Crichton-11/+14
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-18Register new snapshotsAlex Crichton-11/+0
2013-09-16Add an SendStr typeMarvin Löbel-3/+4
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-14std::logging: Use a more specific enum than Eitherblake2-ppc-4/+3
2013-09-05Remove the __log function for __log_levelAlex Crichton-1/+8
Also redefine all of the standard logging macros to use more rust code instead of custom LLVM translation code. This makes them a bit easier to understand, but also more flexibile for future types of logging. Additionally, this commit removes the LogType language item in preparation for changing how logging is performed.
2013-08-28Remove @io::Writer from sys/repr/reflectAlex Crichton-8/+2
At the same time, this updates the TyVisitor to use a mutable self because it's probably going to be mutating state as it goes along anyway.
2013-08-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-1/+2
This removes the stacking of type parameters that occurs when invoking trait methods, and fixes all places in the standard library that were relying on it. It is somewhat awkward in places; I think we'll probably want something like the `Foo::<for T>::new()` syntax.
2013-08-09Remove the C++ runtime. SayonaraBrian Anderson-46/+6
2013-08-04std: Fix newsched logging truncationBrian Anderson-10/+0
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-03fixed the buffer to make it a more reasonable sizetoddaaro-1/+1
2013-08-03modified logging function to truncate output and adjusted error output ↵toddaaro-0/+10
formatting tests to be compatible with both the new and old runtimes
2013-08-02librustc: Disallow "unsafe" for external functionsPatrick Walton-5/+5
2013-07-20librustc: Remove `pub extern` and `priv extern` from the language.Patrick Walton-6/+6
Place `pub` or `priv` on individual items instead.
2013-06-21std: Make console log off/on controls work with newschedBrian Anderson-4/+20
2013-05-30Require documentation by default for libstdAlex Crichton-0/+1
Adds documentation for various things that I understand. Adds #[allow(missing_doc)] for lots of things that I don't understand.
2013-05-28Silence various warnings throughout test modulesAlex Crichton-3/+3
2013-05-22libstd: Rename libcore to libstd and libstd to libextra; update makefiles.Patrick Walton-0/+97
This only changes the directory names; it does not change the "real" metadata names.