Last change
on this file since 3085 was
3070,
checked in by Takeshi Nakazato, 9 years ago
|
New Development: No
JIRA Issue: No
Ready for Test: Yes
Interface Changes: Yes/No?
What Interface Changed: Please list interface changes
Test Programs: List test programs
Put in Release Notes: Yes/No?
Module(s): Module Names change impacts.
Description: Describe your changes here...
Initialize priority parameter. Add support for debug priority.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[1797] | 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, |
---|
[1859] | 23 | const std::string& priority, |
---|
| 24 | const std::string& origin) |
---|
[1797] | 25 | { |
---|
[3070] | 26 | LogMessage::Priority p = LogMessage::NORMAL; |
---|
[1797] | 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; |
---|
[3070] | 33 | } else if (priority == "DEBUG") { |
---|
| 34 | p = LogMessage::DEBUGGING; |
---|
[1797] | 35 | } |
---|
[1859] | 36 | LogMessage message(msg, LogOrigin(origin), p); |
---|
[1797] | 37 | |
---|
| 38 | MemoryLogSink::postLocally(message); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | std::string AsapLogSink::popMessages() |
---|
| 42 | { |
---|
| 43 | ostringstream oss; |
---|
| 44 | for (uInt i=0; i < nelements(); ++i) { |
---|
| 45 | std::string p = getPriority(i); |
---|
| 46 | if (p != "INFO") { |
---|
| 47 | oss << p << ": "; |
---|
| 48 | } |
---|
| 49 | oss << getMessage(i) << endl; |
---|
| 50 | } |
---|
| 51 | clearLocally(); |
---|
| 52 | return String(oss); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | void setAsapSink(AsapLogSink& sink) |
---|
| 56 | { |
---|
| 57 | LogSinkInterface* s = &sink; |
---|
| 58 | LogSink().globalSink(s); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | }; |
---|
Note: See
TracBrowser
for help on using the repository browser.