no message

master
zcy 2021-05-25 22:20:08 +08:00
parent 76b6f19e3e
commit 6865afce40
6 changed files with 52 additions and 16 deletions

View File

@ -22,15 +22,15 @@ endif()
# copy header files # copy header files
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj) SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/obj)
set(COPYITEM inc) set(COPYITEM inc)
file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/inc/*) file(GLOB INCLUDES ${PROJECT_SOURCE_DIR}/general/inc/*)
file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc file(COPY ${INCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
message("include dir " ${INCLUDES}) message("include dir \n" ${INCLUDES})
file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*) file(GLOB PatternINCLUDES ${PROJECT_SOURCE_DIR}/general/src/pattern/*)
file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/pattern file(COPY ${PatternINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/pattern
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
message( "copy pattern library" ${PatternINCLUDES}) message( "copy pattern library \n" ${PatternINCLUDES})
file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h) file(GLOB EncryptINCLUDES ${PROJECT_SOURCE_DIR}/general/src/encrypt/*.h)
file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/encrypt file(COPY ${EncryptINCLUDES} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/encrypt
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
@ -38,11 +38,11 @@ file(GLOB MathINCLUDES ${PROJECT_SOURCE_DIR}/general/src/math/*.hpp)
message( "copy math library" ${MathINCLUDES}) message( "copy math library" ${MathINCLUDES})
add_custom_command(TARGET generallib PRE_LINK add_custom_command(TARGET generallib PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/general/src/math/eigen ${LIBRARY_OUTPUT_PATH}/inc/math/eigen) COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/general/src/math/eigen ${LIBRARY_OUTPUT_PATH}/inc/math/eigen)
message( "copy third library") message( "copy third library \n")
file(GLOB THIRD ${PROJECT_SOURCE_DIR}/general/third/include/*) file(GLOB THIRD ${PROJECT_SOURCE_DIR}/general/third/include/*)
file(COPY ${THIRD} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/third/include/ file(COPY ${THIRD} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/third/include/
FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ) FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_WRITE GROUP_READ WORLD_READ)
message( "copy net ") message( "copy net \n")
file(GLOB NET ${PROJECT_SOURCE_DIR}/general/src/net/*.h) file(GLOB NET ${PROJECT_SOURCE_DIR}/general/src/net/*.h)
file(COPY ${NET} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/ file(COPY ${NET} DESTINATION ${LIBRARY_OUTPUT_PATH}/inc/

View File

@ -14,6 +14,7 @@
using namespace std; using namespace std;
namespace Loger{ namespace Loger{
typedef enum Mode{ typedef enum Mode{
Mode_Daily, // 每天保存一次日志 Mode_Daily, // 每天保存一次日志
MODE_Monthly, // 每个月保存一次日志 MODE_Monthly, // 每个月保存一次日志
@ -31,7 +32,7 @@ namespace Loger{
_C_Loger(FILE *p); _C_Loger(FILE *p);
_C_Loger(string path); _C_Loger(string path);
int Debug(); int Debug(string,string,int);
int Log(); int Log();
int LogFile(); int LogFile();
void operator+(const string&); void operator+(const string&);

View File

@ -1,21 +1,15 @@
// //
// Created by 29019 on 2019/5/2. // Created by 29019 on 2019/5/2.
// //
#ifndef CUTILS_UTILS_H #ifndef CUTILS_UTILS_H
#define CUTILS_UTILS_H #define CUTILS_UTILS_H
#include <string> #include <string>
#include "debug.h" #include "debug.h"
#include <sys/types.h> #include <sys/types.h>
using namespace std; using namespace std;
typedef enum { typedef enum {
ENV_WINDOWS = 1, ENV_WINDOWS = 1,
ENV_LINUX, ENV_LINUX,

View File

@ -21,6 +21,36 @@ string getTime()
return string(tmp); return string(tmp);
} }
int _C_Loger::Debug(string dat,string function,int line){
// 还没有过天
if(getTimeDate() == this->mCurrentDate){
string tmp = getTime();
tmp += ":";
tmp += dat;
tmp += "at [" + function + " line " + std::to_string(line) + "]";
tmp += "\n";
int ret =fwrite(tmp.c_str(),tmp.size(),1,this->mFile);
fflush(this->mFile);
return ret;
}else{ // 已经过天了
this->mCurrentDate = getTimeDate();
string path = getTimeDate() + ".log";
this->mFile = fopen(path.c_str(),"w+");
if (this->mFile == nullptr){
this->error = true;
}
string tmp = getTime();
tmp += ":";
tmp += dat;
tmp += "at [" + function + " line " + std::to_string(line) + "]";
tmp += "\n";
int ret = fwrite(tmp.c_str(),tmp.size(),1,this->mFile);
fflush(this->mFile);
return ret;
}
return 0;
}
void _C_Loger::operator<<(const string& wb){ void _C_Loger::operator<<(const string& wb){
// 还没有过天 // 还没有过天
if(getTimeDate() == this->mCurrentDate){ if(getTimeDate() == this->mCurrentDate){
@ -38,7 +68,9 @@ void _C_Loger::operator<<(const string& wb){
this->error = true; this->error = true;
} }
} }
fprintf(this->mFile,wb.c_str(),wb.size());
} }
bool file_existed(string path) { bool file_existed(string path) {
fstream _file; fstream _file;
_file.open(path.c_str(),ios::in); _file.open(path.c_str(),ios::in);
@ -56,6 +88,7 @@ _C_Loger::_C_Loger(FILE *p){
this->mFile = p; this->mFile = p;
this->mCurrentDate = getTime(); this->mCurrentDate = getTime();
} }
_C_Loger::_C_Loger(string path) { _C_Loger::_C_Loger(string path) {
this->mCurrentDate = getTimeDate(); this->mCurrentDate = getTimeDate();
this->mCurrentPath = path + this->mCurrentDate; this->mCurrentPath = path + this->mCurrentDate;

View File

@ -7,7 +7,11 @@ message("current dir" ${CMAKE_CURRENT_SOURCE_DIR})
aux_source_directory(. SOURCE) aux_source_directory(. SOURCE)
message(info ${SOURCE}) message(info ${SOURCE})
link_directories("./third/jsoncpp/lib/") link_directories("./third/jsoncpp/lib/")
link_directories("../../../obj/")
link_libraries(jsoncpp) link_libraries(jsoncpp)
link_libraries(generallib)
add_executable(cpp11 ${SOURCE} ) add_executable(cpp11 ${SOURCE} )
include_directories("./third/jsoncpp/include/pkgsrc/include/json") include_directories("./third/jsoncpp/include/pkgsrc/include/json")
include_directories("../../../obj/inc/") include_directories("../../../obj/inc/")

View File

@ -8,11 +8,12 @@ using namespace std;
#include "threadpool.h" #include "threadpool.h"
#include "json.h" #include "json.h"
#include "template.h" #include "template.h"
extern "C"{ extern "C"{
#include<stdio.h> #include<stdio.h>
#include <time.h> #include <time.h>
} }
#include "loger.h"
int main(){ int main(){
// std::cout<<"test start"<<endl; // std::cout<<"test start"<<endl;
@ -22,5 +23,8 @@ int main(){
// }catch( std::exception e){ // }catch( std::exception e){
// std::cout<<"exception"<<e.what(); // std::cout<<"exception"<<e.what();
// } // }
TestRingBuffer(); Loger::Loger loger("d://");
loger.Debug("ces",__FILE__,__LINE__);
std::cout<<"line " << __FILE__<<__LINE__<<" "<<__FUNCTION__<<std::endl;
// TestRingBuffer();
} }