UniSet  2.6.0
LogServerTypes.h
00001 /*
00002  * Copyright (c) 2015 Pavel Vainerman.
00003  *
00004  * This program is free software: you can redistribute it and/or modify
00005  * it under the terms of the GNU Lesser General Public License as
00006  * published by the Free Software Foundation, version 2.1.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00011  * Lesser General Lesser Public License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00015  */
00016 // -------------------------------------------------------------------------
00017 #ifndef LogServerTypes_H_
00018 #define LogServerTypes_H_
00019 // -------------------------------------------------------------------------
00020 #include <ostream>
00021 #include <cstring>
00022 // -------------------------------------------------------------------------
00023 namespace uniset
00024 {
00025 
00026 namespace LogServerTypes
00027 {
00028 const unsigned int MAGICNUM = 0x20160417;
00029 enum Command
00030 {
00031     cmdNOP,         
00032     cmdSetLevel,    
00033     cmdAddLevel,    
00034     cmdDelLevel,    
00035     cmdRotate,      
00036     cmdOffLogFile,  
00037     cmdOnLogFile,   
00039     // работа с логами по умолчанию
00040     cmdSaveLogLevel,   
00041     cmdRestoreLogLevel, 
00043     // команды требующий ответа..
00044     cmdList,        
00045     cmdFilterMode,  
00046     cmdViewDefaultLogLevel  
00047     // cmdSetLogFile
00048 };
00049 
00050 std::ostream& operator<<(std::ostream& os, Command c );
00051 
00052 struct lsMessage
00053 {
00054     lsMessage(): magic(MAGICNUM), cmd(cmdNOP), data(0)
00055     {
00056         std::memset(logname, 0, sizeof(logname));
00057     }
00058     unsigned int magic;
00059     Command cmd;
00060     unsigned int data;
00061 
00062     static const size_t MAXLOGNAME = 30;
00063     char logname[MAXLOGNAME + 1]; // +1 reserverd for '\0'
00064 
00065     void setLogName( const std::string& name );
00066 
00067     // для команды 'cmdSetLogFile'
00068     // static const size_t MAXLOGFILENAME = 200;
00069     // char logfile[MAXLOGFILENAME];
00070 } __attribute__((packed));
00071 
00072 std::ostream& operator<<(std::ostream& os, lsMessage& m );
00073 }
00074 // -------------------------------------------------------------------------
00075 } // end of uniset namespace
00076 // -------------------------------------------------------------------------
00077 #endif // LogServerTypes_H_
00078 // -------------------------------------------------------------------------