diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-05-02 14:48:54 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-05-02 14:48:54 -0400 |
commit | 6c49cef53c727bd8efde33fd78431f2945a28036 (patch) | |
tree | 2630c303a9865cc8b7be722f8f9397e7626648ca | |
parent | aaad7824cddd8db18263346c1258ad86ce76abec (diff) | |
download | mongo-6c49cef53c727bd8efde33fd78431f2945a28036.tar.gz |
don't include newline in RamLog
-rw-r--r-- | util/ramlog.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/util/ramlog.cpp b/util/ramlog.cpp index 00e07b7cfa3..8238312ac74 100644 --- a/util/ramlog.cpp +++ b/util/ramlog.cpp @@ -49,10 +49,20 @@ namespace mongo { void RamLog::write(LogLevel ll, const string& str) { char *p = lines[(h+n)%N]; - if( str.size() < C ) - strcpy(p, str.c_str()); - else + + unsigned sz = str.size(); + if( sz < C ) { + if ( str.c_str()[sz-1] == '\n' ) { + memcpy(p, str.c_str(), sz-1); + p[sz-1] = 0; + } + else + strcpy(p, str.c_str()); + } + else { memcpy(p, str.c_str(), C-1); + } + if( n < N ) n++; else h = (h+1) % N; } |