UniSet  2.8.0
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 uint MAGICNUM = 0x20160417;
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(): magic(MAGICNUM), cmd(cmdNOP), data(0)
56  {
57  std::memset(logname, 0, sizeof(logname));
58  }
59 
60  explicit lsMessage( Command c, uint d, const std::string& logname ):
61  magic(MAGICNUM), cmd(c), data(d)
62  {
63  setLogName(logname);
64  }
65 
66  uint magic;
67  Command cmd;
68  uint data;
69 
70  static const size_t MAXLOGNAME = 120;
71  char logname[MAXLOGNAME + 1]; // +1 reserverd for '\0'
72 
73  void setLogName( const std::string& name );
74 
75  // для команды 'cmdSetLogFile'
76  // static const size_t MAXLOGFILENAME = 200;
77  // char logfile[MAXLOGFILENAME];
78  } __attribute__((packed));
79 
80  std::ostream& operator<<(std::ostream& os, const lsMessage& m );
81 
90  std::vector<lsMessage> getCommands( const std::string& cmd );
91  }
92  // -------------------------------------------------------------------------
93 } // end of uniset namespace
94 // -------------------------------------------------------------------------
95 #endif // LogServerTypes_H_
96 // -------------------------------------------------------------------------
Definition: CommonEventLoop.h:14
Definition: LogServerTypes.h:53