]> git.lizzy.rs Git - rust.git/commit
std: Make logging safely implemented
authorAlex Crichton <alex@alexcrichton.com>
Fri, 13 Dec 2013 01:34:29 +0000 (17:34 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 24 Dec 2013 22:42:00 +0000 (14:42 -0800)
commit76270816d527bfceef64bf6cbdc64f985ca73eba
tree1b620e0a90a0119e309ff560e2214152e9d608f1
parentdd19785f963fd1045e53447add17ab36ca41fc79
std: Make logging safely implemented

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).
src/libstd/logging.rs