<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/src/libstd/logging.rs, branch try</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=try</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=try'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2014-03-16T05:26:36+00:00</updated>
<entry>
<title>log: Introduce liblog, the old std::logging</title>
<updated>2014-03-16T05:26:36+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-03-09T06:11:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=cc6ec8df95fbd8163b7c2c6c34469fb96b704e66'/>
<id>urn:sha1:cc6ec8df95fbd8163b7c2c6c34469fb96b704e66</id>
<content type='text'>
This commit moves all logging out of the standard library into an external
crate. This crate is the new crate which is responsible for all logging macros
and logging implementation. A few reasons for this change are:

* The crate map has always been a bit of a code smell among rust programs. It
  has difficulty being loaded on almost all platforms, and it's used almost
  exclusively for logging and only logging. Removing the crate map is one of the
  end goals of this movement.

* The compiler has a fair bit of special support for logging. It has the
  __log_level() expression as well as generating a global word per module
  specifying the log level. This is unfairly favoring the built-in logging
  system, and is much better done purely in libraries instead of the compiler
  itself.

* Initialization of logging is much easier to do if there is no reliance on a
  magical crate map being available to set module log levels.

* If the logging library can be written outside of the standard library, there's
  no reason that it shouldn't be. It's likely that we're not going to build the
  highest quality logging library of all time, so third-party libraries should
  be able to provide just as high-quality logging systems as the default one
  provided in the rust distribution.

With a migration such as this, the change does not come for free. There are some
subtle changes in the behavior of liblog vs the previous logging macros:

* The core change of this migration is that there is no longer a physical
  log-level per module. This concept is still emulated (it is quite useful), but
  there is now only a global log level, not a local one. This global log level
  is a reflection of the maximum of all log levels specified. The previously
  generated logging code looked like:

    if specified_level &lt;= __module_log_level() {
        println!(...)
    }

  The newly generated code looks like:

    if specified_level &lt;= ::log::LOG_LEVEL {
        if ::log::module_enabled(module_path!()) {
            println!(...)
        }
    }

  Notably, the first layer of checking is still intended to be "super fast" in
  that it's just a load of a global word and a compare. The second layer of
  checking is executed to determine if the current module does indeed have
  logging turned on.

  This means that if any module has a debug log level turned on, all modules
  with debug log levels get a little bit slower (they all do more expensive
  dynamic checks to determine if they're turned on or not).

  Semantically, this migration brings no change in this respect, but
  runtime-wise, this will have a perf impact on some code.

* A `RUST_LOG=::help` directive will no longer print out a list of all modules
  that can be logged. This is because the crate map will no longer specify the
  log levels of all modules, so the list of modules is not known. Additionally,
  warnings can no longer be provided if a malformed logging directive was
  supplied.

The new "hello world" for logging looks like:

    #[phase(syntax, link)]
    extern crate log;

    fn main() {
        debug!("Hello, world!");
    }
</content>
</entry>
<entry>
<title>std: Switch stdout/stderr to buffered by default</title>
<updated>2014-03-01T18:06:20+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-02-28T20:55:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2cb83fdd7ea4e76d4b1c830a97480521cc405625'/>
<id>urn:sha1:2cb83fdd7ea4e76d4b1c830a97480521cc405625</id>
<content type='text'>
Similarly to #12422 which made stdin buffered by default, this commit makes the
output streams also buffered by default. Now that buffered writers will flush
their contents when they are dropped, I don't believe that there's no reason why
the output shouldn't be buffered by default, which is what you want in 90% of
cases.

As with stdin, there are new stdout_raw() and stderr_raw() functions to get
unbuffered streams to stdout/stderr.
</content>
</entry>
<entry>
<title>Move std::{trie, hashmap} to libcollections</title>
<updated>2014-02-23T08:35:11+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-02-20T03:29:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=2a14e084cfd8cf9a9149d0b7c6329b0dad0521d0'/>
<id>urn:sha1:2a14e084cfd8cf9a9149d0b7c6329b0dad0521d0</id>
<content type='text'>
These two containers are indeed collections, so their place is in
libcollections, not in libstd. There will always be a hash map as part of the
standard distribution of Rust, but by moving it out of the standard library it
makes libstd that much more portable to more platforms and environments.

This conveniently also removes the stuttering of 'std::hashmap::HashMap',
although 'collections::HashMap' is only one character shorter.
</content>
</entry>
<entry>
<title>Fix all code examples</title>
<updated>2014-02-15T07:49:22+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-02-15T07:44:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=e72ddbdc25a2696a41053832fad7d9b0428819af'/>
<id>urn:sha1:e72ddbdc25a2696a41053832fad7d9b0428819af</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Move replace and swap to std::mem. Get rid of std::util</title>
<updated>2014-02-10T21:21:35+00:00</updated>
<author>
<name>Edward Wang</name>
<email>edward.yu.wang@gmail.com</email>
</author>
<published>2014-01-31T20:35:36+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=e9ff91e9beb6c92d9662242c1090c507b1611c59'/>
<id>urn:sha1:e9ff91e9beb6c92d9662242c1090c507b1611c59</id>
<content type='text'>
Also move Void to std::any, move drop to std::mem and reexport in
prelude.
</content>
</entry>
<entry>
<title>std: Remove io::io_error</title>
<updated>2014-02-03T17:32:33+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-01-30T00:33:57+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ece8a8f520697be50cbe543bebe065c5198dae4d'/>
<id>urn:sha1:ece8a8f520697be50cbe543bebe065c5198dae4d</id>
<content type='text'>
* All I/O now returns IoResult&lt;T&gt; = Result&lt;T, IoError&gt;
* All formatting traits now return fmt::Result = IoResult&lt;()&gt;
* The if_ok!() macro was added to libstd
</content>
</entry>
<entry>
<title>Tweak the interface of std::io</title>
<updated>2014-01-17T18:00:47+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-01-15T21:25:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=295b46fc08c8cc6da0a144cd90c401d5b26a1faf'/>
<id>urn:sha1:295b46fc08c8cc6da0a144cd90c401d5b26a1faf</id>
<content type='text'>
* 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)
</content>
</entry>
<entry>
<title>Support arbitrary stdout/stderr/logger handles</title>
<updated>2014-01-06T21:19:53+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2014-01-06T18:26:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ac2a24ecc9df66279a7b6df478593b34e1d2449f'/>
<id>urn:sha1:ac2a24ecc9df66279a7b6df478593b34e1d2449f</id>
<content type='text'>
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
</content>
</entry>
<entry>
<title>std: uniform modules titles for doc</title>
<updated>2013-12-27T08:49:11+00:00</updated>
<author>
<name>Luca Bruno</name>
<email>lucab@debian.org</email>
</author>
<published>2013-12-24T16:08:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a9a7a427a1f1a61497105283594d32b976d7559f'/>
<id>urn:sha1:a9a7a427a1f1a61497105283594d32b976d7559f</id>
<content type='text'>
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 &lt;lucab@debian.org&gt;
</content>
</entry>
<entry>
<title>std: Make logging safely implemented</title>
<updated>2013-12-24T22:42:00+00:00</updated>
<author>
<name>Alex Crichton</name>
<email>alex@alexcrichton.com</email>
</author>
<published>2013-12-13T01:34:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=76270816d527bfceef64bf6cbdc64f985ca73eba'/>
<id>urn:sha1:76270816d527bfceef64bf6cbdc64f985ca73eba</id>
<content type='text'>
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).
</content>
</entry>
</feed>
