-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiagnostic.cc
110 lines (84 loc) · 1.94 KB
/
Diagnostic.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// -*- C++ -*-
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Michael A.G. Aivazis
// California Institute of Technology
// (C) 1998-2005 All Rights Reserved
//
// <LicenseText>
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
#include <portinfo>
#include <string>
#include <sstream>
#include <map>
#include <vector>
#include "Diagnostic.h"
#include "Facility.h"
#include "Entry.h"
#include "Device.h"
#include "Journal.h"
using namespace journal;
// interface
Diagnostic::journal_t & Diagnostic::journal() {
// statics
static Diagnostic::journal_t * _journal = new Journal();
return *_journal;
}
bool Diagnostic::state() const {
return _state.state();
}
void Diagnostic::state(bool flag) {
_state.state(flag);
return;
}
void Diagnostic::record() {
if (!_state.state()) {
return;
}
_newline();
// record the journal entry
journal().record(*_entry);
// reset the entry
delete _entry;
_entry = new Entry;
(*_entry)["severity"] = _severity;
(*_entry)["facility"] = _facility;
return;
}
void Diagnostic::newline() {
if (!_state.state()) {
return;
}
_newline();
return;
}
void Diagnostic::attribute(string_t key, string_t value) {
(*_entry)[key] = value;
return;
}
// meta-methods
Diagnostic::~Diagnostic()
{
delete _entry;
}
Diagnostic::Diagnostic(string_t facility, string_t severity, state_t & state):
_facility(facility), _severity(severity),
_state(state),
_buffer(),
_entry(new entry_t)
{
(*_entry)["facility"] = facility;
(*_entry)["severity"] = severity;
}
// implementation
void Diagnostic::_newline() {
_entry->newline(str());
_buffer.str(string_t());
return;
}
// version
// $Id: Diagnostic.cc,v 1.1.1.1 2006-11-27 00:09:37 aivazis Exp $
// End of file