diff options
author | samantharitter <samantha.ritter@10gen.com> | 2017-05-25 17:51:17 -0400 |
---|---|---|
committer | samantharitter <samantha.ritter@10gen.com> | 2017-05-30 11:22:57 -0400 |
commit | fad590916a30ff34dc8c3b37afcfffa2c4e5c8bc (patch) | |
tree | c57610dde742c1e17316b756c9ccb4215ce58db6 /src/mongo/util | |
parent | 6a11fc05770306b5d660b21f339cba110d6d67d4 (diff) | |
download | mongo-fad590916a30ff34dc8c3b37afcfffa2c4e5c8bc.tar.gz |
SERVER-29152 Do not cache logging ostream in threadlocal when in other thread-specific contexts
Diffstat (limited to 'src/mongo/util')
-rw-r--r-- | src/mongo/util/log.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/util/log.h b/src/mongo/util/log.h index aed08960309..662db7afe47 100644 --- a/src/mongo/util/log.h +++ b/src/mongo/util/log.h @@ -133,6 +133,22 @@ inline LogstreamBuilder log() { ::MongoLogDefaultComponent_component); } +/** + * Returns a LogstreamBuilder that does not cache its ostream in a threadlocal cache. + * Use this variant when logging from places that may not be able to access threadlocals, + * such as from within other threadlocal-managed objects, or thread_specific_ptr-managed + * objects. + * + * Once SERVER-29377 is completed, this overload can be removed. + */ +inline LogstreamBuilder logNoCache() { + return LogstreamBuilder(logger::globalLogDomain(), + getThreadName(), + logger::LogSeverity::Log(), + ::MongoLogDefaultComponent_component, + false); +} + inline LogstreamBuilder log(logger::LogComponent component) { return LogstreamBuilder( logger::globalLogDomain(), getThreadName(), logger::LogSeverity::Log(), component); |