M1M3 Support System
Loading...
Searching...
No Matches
SALSink.h
1/*
2 * This file is part of LSST M1M3 support system package.
3 *
4 * Developed for the LSST Telescope and Site Systems.
5 * This product includes software developed by the LSST Project
6 * (https://www.lsst.org).
7 * See the COPYRIGHT file at the top-level directory of this distribution
8 * for details of code ownership.
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef SALSINK_H_
25#define SALSINK_H_
26
27#include "spdlog/sinks/base_sink.h"
28
29#include <SAL_MTM1M3.h>
30
31#include <memory>
32
33namespace LSST {
34namespace M1M3 {
35namespace SS {
36
42template <typename Mutex>
43class SALSink : public spdlog::sinks::base_sink<Mutex> {
44public:
45 SALSink(std::shared_ptr<SAL_MTM1M3> m1m3SAL) {
46 _m1m3SAL = m1m3SAL;
47 _m1m3SAL->salEventPub((char *)"MTM1M3_logevent_logMessage");
48 }
49
50protected:
51 void sink_it_(const spdlog::details::log_msg &msg) override {
52 spdlog::memory_buf_t formatted;
53 spdlog::sinks::base_sink<Mutex>::formatter_->format(msg, formatted);
54
55 MTM1M3_logevent_logMessageC message;
56 message.name = "MTM1M3";
57 message.level = msg.level * 10;
58 message.message = fmt::to_string(msg.payload);
59 message.traceback = "";
60 message.filePath = msg.source.filename;
61 message.functionName = msg.source.funcname;
62 message.lineNumber = msg.source.line;
63 message.process = getpid();
64
65 _m1m3SAL->logEvent_logMessage(&message, 0);
66 }
67
68 void flush_() override {}
69
70private:
71 std::shared_ptr<SAL_MTM1M3> _m1m3SAL;
72};
73
74#include "spdlog/details/null_mutex.h"
75#include <mutex>
78
79} // namespace SS
80} // namespace M1M3
81} // namespace LSST
82
83#endif // SALSINK_H_
Sink to send all M1M3 spdlog messages to SAL using logMessage event.
Definition SALSink.h:43