source: branches/alma/src/AsapLogSink.cpp@ 2812

Last change on this file since 2812 was 1818, checked in by Kana Sugimoto, 14 years ago

New Development: Yes

JIRA Issue: No (merge)

Ready for Test: Yes

Interface Changes: No

Description:

Merged changes -r1774:1817 in newfiller branch to alma branch


File size: 1.3 KB
RevLine 
[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
18using namespace casa;
19
20namespace asap {
21
22 void AsapLogSink::postMessage(const std::string& msg,
23 const std::string& location,
24 const std::string& priority)
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(location), 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.