MongoDB C++ Driver  legacy-1.1.2
message_event.h
1 /* Copyright 2013 10gen Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include "mongo/base/string_data.h"
19 #include "mongo/logger/log_component.h"
20 #include "mongo/logger/log_severity.h"
21 #include "mongo/platform/cstdint.h"
22 #include "mongo/util/time_support.h"
23 
24 namespace mongo {
25 namespace logger {
26 
34 public:
36  LogSeverity severity,
37  StringData contextName,
38  StringData message)
39  : _date(date),
40  _severity(severity),
41  _component(LogComponent::kDefault),
42  _contextName(contextName),
43  _message(message) {}
44 
46  LogSeverity severity,
47  LogComponent component,
48  StringData contextName,
49  StringData message)
50  : _date(date),
51  _severity(severity),
52  _component(component),
53  _contextName(contextName),
54  _message(message) {}
55 
56  uint64_t getDate() const {
57  return _date;
58  }
59  LogSeverity getSeverity() const {
60  return _severity;
61  }
62  LogComponent getComponent() const {
63  return _component;
64  }
65  StringData getContextName() const {
66  return _contextName;
67  }
68  StringData getMessage() const {
69  return _message;
70  }
71 
72 private:
73  Date_t _date;
74  LogSeverity _severity;
75  LogComponent _component;
76  StringData _contextName;
77  StringData _message;
78 };
79 
80 } // namespace logger
81 } // namespace mongo
Log components.
Definition: log_component.h:32
A StringData object wraps a 'const string&' or a 'const char*' without copying its contents...
Definition: string_data.h:43
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
Free form text log message object that does not own the storage behind its message and contextName...
Definition: message_event.h:33
Definition: time_support.h:39
Representation of the severity / priority of a log message.
Definition: log_severity.h:33