Last change
on this file since 2201 was 1859, checked in by Malte Marquarding, 14 years ago |
Ticket #193: the rcParamsverbose flag is only used in standard asap cli mode. Otherwise log messages are always send to the logger and one needs to call asaplog.disable()/asaplog.enable() to controls this. I have also added the function name as the log origin.
|
File size:
1.3 KB
|
Line | |
---|
1 | //
|
---|
2 | // C++ Implementation: AsapLogSink
|
---|
3 | //
|
---|
4 | // Description:
|
---|
5 | //
|
---|
6 | //
|
---|
7 | // Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2010
|
---|
8 | //
|
---|
9 | // Copyright: See COPYING file that comes with this distribution
|
---|
10 | //
|
---|
11 | //
|
---|
12 | #include <casa/iostream.h>
|
---|
13 | #include <casa/Logging/LogMessage.h>
|
---|
14 | #include <casa/Logging/LogSink.h>
|
---|
15 | #include <casa/Logging/NullLogSink.h>
|
---|
16 | #include "AsapLogSink.h"
|
---|
17 |
|
---|
18 | using namespace casa;
|
---|
19 |
|
---|
20 | namespace asap {
|
---|
21 |
|
---|
22 | void AsapLogSink::postMessage(const std::string& msg,
|
---|
23 | const std::string& priority,
|
---|
24 | const std::string& origin)
|
---|
25 | {
|
---|
26 | LogMessage::Priority p;
|
---|
27 | if (priority == "INFO") {
|
---|
28 | p = LogMessage::NORMAL;
|
---|
29 | } else if (priority == "WARN") {
|
---|
30 | p = LogMessage::WARN;
|
---|
31 | } else if (priority == "ERROR") {
|
---|
32 | p = LogMessage::SEVERE;
|
---|
33 | }
|
---|
34 | LogMessage message(msg, LogOrigin(origin), p);
|
---|
35 |
|
---|
36 | MemoryLogSink::postLocally(message);
|
---|
37 | }
|
---|
38 |
|
---|
39 | std::string AsapLogSink::popMessages()
|
---|
40 | {
|
---|
41 | ostringstream oss;
|
---|
42 | for (uInt i=0; i < nelements(); ++i) {
|
---|
43 | std::string p = getPriority(i);
|
---|
44 | if (p != "INFO") {
|
---|
45 | oss << p << ": ";
|
---|
46 | }
|
---|
47 | oss << getMessage(i) << endl;
|
---|
48 | }
|
---|
49 | clearLocally();
|
---|
50 | return String(oss);
|
---|
51 | }
|
---|
52 |
|
---|
53 | void setAsapSink(AsapLogSink& sink)
|
---|
54 | {
|
---|
55 | LogSinkInterface* s = &sink;
|
---|
56 | LogSink().globalSink(s);
|
---|
57 | }
|
---|
58 |
|
---|
59 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.