UniSet  2.12.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 // -------------------------------------------------------------------------
24 namespace 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,
40  // работа с логами по умолчанию
41  cmdSaveLogLevel,
42  cmdRestoreLogLevel,
44  // команды требующие ответа..
45  cmdList,
46  cmdFilterMode,
47  cmdViewDefaultLogLevel
48  // cmdSetLogFile
49  };
50 
51  std::ostream& operator<<(std::ostream& os, Command c );
52 
53  struct lsMessage
54  {
55  lsMessage();
56  explicit lsMessage( Command c, uint32_t d, const std::string& logname );
57 
58  uint8_t _be_order; // 1 - BE byte order, 0 - LE byte order
59  uint32_t magic;
60  uint32_t data;
61  uint8_t cmd;
62 
63  static const size_t MAXLOGNAME = 120;
64  char logname[MAXLOGNAME + 1]; // +1 reserverd for '\0'
65 
66  void setLogName( const std::string& name );
67  void convertFromNet() noexcept;
68 
69  // для команды 'cmdSetLogFile'
70  // static const size_t MAXLOGFILENAME = 200;
71  // char logfile[MAXLOGFILENAME];
72  } __attribute__((packed));
73 
74  std::ostream& operator<<(std::ostream& os, const lsMessage& m );
75 
84  std::vector<lsMessage> getCommands( const std::string& cmd );
85  }
86  // -------------------------------------------------------------------------
87 } // end of uniset namespace
88 // -------------------------------------------------------------------------
89 #endif // LogServerTypes_H_
90 // -------------------------------------------------------------------------
Definition: CommonEventLoop.h:14
Definition: LogServerTypes.h:53