#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fstream>
using namespace std;
#define DELIM_Fenge "\r\t\n"
#define DELIM_Douhao ","
#define DELIM_Fenghao ";"
#define DELIM_Yinhao "\""
int main()
{
ifstream in("1.txt");
ofstream out("2.txt");
string str_line;
char textTrace[1024];
if(in)
{
while(getline(in,str_line))
{
//cout<<str_line<<endl;
if( strstr(str_line.c_str(),"RrmLogTrace") )
{
string traceString;
traceString += str_line;
while(getline(in,str_line))
{
traceString += str_line;
if( strstr(str_line.c_str(),DELIM_Fenghao) )
break;
}
//cout<<traceString<<endl;
//solve=================================
char tmpTraceString[1024];
strcpy(tmpTraceString,traceString.c_str());
char *tPtr = strtok(tmpTraceString ,DELIM_Douhao);
int i = 0;
while( tPtr )
{
//预留处理告警等级INFO ERROR
//cout<<tPtr<<endl;
if( strstr(tPtr,DELIM_Yinhao) )
{
cout<<"!!!"<<tPtr<<endl;
for(i = 0 ; i < strlen(tPtr); ++i )
{
textTrace[i] = tPtr[i];
if(i != 0 && tPtr[i] == '"') break;
}
textTrace[++i] = '\0';
}
if( i != 0 )
{
i = 0;
break;
}
tPtr = strtok(NULL,DELIM_Douhao);
}
str_line = "RRM_INFO_LOG(";
str_line += textTrace;
str_line += ");";
//solve=================================
}
out<<str_line<<endl;
}
}
else
{
cout<<"no file"<<endl;
}
return 0;
}
RrmTraceLog
最新推荐文章于 2023-05-17 18:45:57 发布