diff options
Diffstat (limited to 'src/mongo/logger')
-rw-r--r-- | src/mongo/logger/ramlog.cpp | 13 | ||||
-rw-r--r-- | src/mongo/logger/ramlog.h | 5 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/mongo/logger/ramlog.cpp b/src/mongo/logger/ramlog.cpp index 42742f32bcc..e0190577f71 100644 --- a/src/mongo/logger/ramlog.cpp +++ b/src/mongo/logger/ramlog.cpp @@ -50,8 +50,7 @@ RM* _named = NULL; } // namespace RamLog::RamLog(const std::string& name) : _name(name), _totalLinesWritten(0), _lastWrite(0) { - h = 0; - n = 0; + clear(); for (int i = 0; i < N; i++) lines[i][C - 1] = 0; } @@ -84,6 +83,16 @@ void RamLog::write(const std::string& str) { h = (h + 1) % N; } +void RamLog::clear() { + stdx::lock_guard<stdx::mutex> lk(_mutex); + _totalLinesWritten = 0; + _lastWrite = 0; + h = 0; + n = 0; + for (int i = 0; i < N; i++) + lines[i][0] = 0; +} + time_t RamLog::LineIterator::lastWrite() { return _ramlog->_lastWrite; } diff --git a/src/mongo/logger/ramlog.h b/src/mongo/logger/ramlog.h index 54901948f74..902471c4563 100644 --- a/src/mongo/logger/ramlog.h +++ b/src/mongo/logger/ramlog.h @@ -93,6 +93,11 @@ public: */ void write(const std::string& str); + /** + * Empties out the RamLog. + */ + void clear(); + /** * Writes an HTML representation of the log to "s". |