UniSet 2.32.1
LogServerTypes.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// -------------------------------------------------------------------------
17#ifndef LogServerTypes_H_
18#define LogServerTypes_H_
19// -------------------------------------------------------------------------
20#include <ostream>
21#include <cstring>
22#include <vector>
23// -------------------------------------------------------------------------
24namespace uniset
25{
26
27 namespace LogServerTypes
28 {
29 const uint32_t MAGICNUM = 20201222;
30 enum Command
31 {
32 cmdNOP,
33 cmdSetLevel,
34 cmdAddLevel,
35 cmdDelLevel,
36 cmdRotate,
37 cmdOffLogFile,
38 cmdOnLogFile,
39 cmdSetVerbosity,
41 // работа с логами по умолчанию
42 cmdSaveLogLevel,
43 cmdRestoreLogLevel,
45 // команды требующие ответа..
46 cmdList,
47 cmdFilterMode,
48 cmdViewDefaultLogLevel,
49 // cmdSetLogFile
50
51 // другие команды
52 cmdShowLocalTime,
53 cmdShowUTCTime
54 };
55
56 std::ostream& operator<<(std::ostream& os, Command c );
57
58 struct lsMessage
59 {
60 lsMessage();
61 explicit lsMessage( Command c, uint32_t d, const std::string& logname );
62
63 uint8_t _be_order; // 1 - BE byte order, 0 - LE byte order
64 uint32_t magic;
65 uint32_t data;
66 uint8_t cmd;
67
68 static const size_t MAXLOGNAME = 120;
69 char logname[MAXLOGNAME + 1]; // +1 reserverd for '\0'
70
71 void setLogName( const std::string& name );
72 void convertFromNet() noexcept;
73
74 // для команды 'cmdSetLogFile'
75 // static const size_t MAXLOGFILENAME = 200;
76 // char logfile[MAXLOGFILENAME];
77 } __attribute__((packed));
78
79 std::ostream& operator<<(std::ostream& os, const lsMessage& m );
80
89 std::vector<lsMessage> getCommands( const std::string& cmd );
90 }
91 // -------------------------------------------------------------------------
92} // end of uniset namespace
93// -------------------------------------------------------------------------
94#endif // LogServerTypes_H_
95// -------------------------------------------------------------------------
Definition Calibration.h:27
Definition LogServerTypes.h:59