MongoDB
2.5.0
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
mongo
util
ramlog.h
1
// ramlog.h
2
3
/* Copyright 2009 10gen Inc.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#pragma once
19
20
#include "log.h"
21
22
namespace
mongo {
23
24
class
RamLog
:
public
Tee
{
25
public
:
26
RamLog
(
const
std::string& name );
27
28
virtual
void
write(LogLevel ll,
const
string
& str);
29
30
void
get
( vector<const char*>& v)
const
;
31
32
void
toHTML(stringstream& s);
33
34
static
RamLog
*
get
(
const
std::string& name );
35
static
void
getNames( vector<string>& names );
36
37
time_t lastWrite() {
return
_lastWrite; }
// 0 if no writes
38
long
long
getTotalLinesWritten()
const
{
return
_totalLinesWritten; }
39
40
protected
:
41
static
int
repeats(
const
vector<const char *>& v,
int
i);
42
static
string
clean(
const
vector<const char *>& v,
int
i,
string
line=
""
);
43
static
string
color(
const
std::string& line);
44
45
/* turn http:... into an anchor */
46
static
string
linkify(
const
char
*s);
47
48
private
:
49
~
RamLog
();
// want this private as we want to leak so we can use them till the very end
50
51
enum
{
52
N = 1024,
// number of lines
53
C = 512
// max size of line
54
};
55
char
lines[N][C];
56
unsigned
h;
// current position
57
unsigned
n;
// number of lines stores 0 o N
58
string
_name;
59
long
long
_totalLinesWritten;
60
61
typedef
map<string,RamLog*> RM;
62
static
mongo::mutex
* _namedLock;
63
static
RM* _named;
64
time_t _lastWrite;
65
};
66
67
}
Generated on Wed May 22 2013 14:16:16 for MongoDB by
1.8.3.1