UniSet  2.6.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 // -------------------------------------------------------------------------
23 namespace uniset
24 {
25 
26  namespace LogServerTypes
27  {
28  const unsigned int MAGICNUM = 0x20160417;
29  enum Command
30  {
31  cmdNOP,
32  cmdSetLevel,
33  cmdAddLevel,
34  cmdDelLevel,
35  cmdRotate,
36  cmdOffLogFile,
37  cmdOnLogFile,
39  // работа с логами по умолчанию
40  cmdSaveLogLevel,
41  cmdRestoreLogLevel,
43  // команды требующий ответа..
44  cmdList,
45  cmdFilterMode,
46  cmdViewDefaultLogLevel
47  // cmdSetLogFile
48  };
49 
50  std::ostream& operator<<(std::ostream& os, Command c );
51 
52  struct lsMessage
53  {
54  lsMessage(): magic(MAGICNUM), cmd(cmdNOP), data(0)
55  {
56  std::memset(logname, 0, sizeof(logname));
57  }
58  unsigned int magic;
59  Command cmd;
60  unsigned int data;
61 
62  static const size_t MAXLOGNAME = 30;
63  char logname[MAXLOGNAME + 1]; // +1 reserverd for '\0'
64 
65  void setLogName( const std::string& name );
66 
67  // для команды 'cmdSetLogFile'
68  // static const size_t MAXLOGFILENAME = 200;
69  // char logfile[MAXLOGFILENAME];
70  } __attribute__((packed));
71 
72  std::ostream& operator<<(std::ostream& os, lsMessage& m );
73  }
74  // -------------------------------------------------------------------------
75 } // end of uniset namespace
76 // -------------------------------------------------------------------------
77 #endif // LogServerTypes_H_
78 // -------------------------------------------------------------------------
Definition: CallbackTimer.h:29
Definition: LogServerTypes.h:52