MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / ProcessMessageRules

Function ProcessMessageRules

source/main.cpp:1207–1264  ·  view source on GitHub ↗

--------------------------------------------------------------------------- return false if message p should be ignored

Source from the content-addressed store, hash-verified

1205//---------------------------------------------------------------------------
1206// return false if message p should be ignored
1207bool ProcessMessageRules(TSyslogMessage * p)
1208{
1209 bool rv = true;
1210 TMessProcessRule * pr;
1211 for(int i=0; i<ProcessRules->Count; i++)
1212 {
1213 pr = ProcessRules->Get(i);
1214 if( ! pr->bEnable )
1215 continue;
1216 if( ! pr->Match.Match(p) )
1217 continue;
1218
1219 if( pr->Process.bIgnore )
1220 {
1221 rv = false;
1222 }
1223 if( pr->Process.bAlarm )
1224 {
1225 AlarmShow(p->Format(pr->Process.AlarmMess));
1226 }
1227 if( pr->Process.bSound )
1228 {
1229 TalkingThread->Play(pr->Process.GetSoundFileName(), pr->Process.PlayCount);
1230 }
1231 if( pr->Process.bSendMail )
1232 {
1233 TLetter l;
1234 l = MainCfg.Letter;
1235 if( pr->Process.Recipient.Length() > 0 )
1236 l.recipient = pr->Process.Recipient;
1237 l.subject = p->Format(l.subject);
1238 l.message = p->Format(l.message);
1239 l.callback = OnReceiveMail;
1240 TSendmailThread::Send(&l);
1241 }
1242 if( pr->Process.bRunProg )
1243 {
1244 DWORD LastError;
1245 String cmd = p->Format(pr->Process.ProgFile);
1246 if( ! RunProg(cmd.c_str(),
1247 pr->Process.bProgHide ? SW_HIDE : SW_SHOWNORMAL,
1248 false, &LastError) )
1249 WriteToLogError("ERROR\tRun program %s: %s",
1250 cmd.c_str(), FormatLastError2(LastError).c_str());
1251 }
1252 if( pr->Process.bSaveToFile )
1253 {
1254 TStorageFile * sf = fdb->GetByNumber( pr->Process.SaveFile );
1255 if( sf )
1256 {
1257 String f = sf->GetFileName();
1258 if( ! sf->Save( p->ToString() ) )
1259 WriteToLogError("ERROR\tSave message to file: %s", f.c_str());
1260 }
1261 }
1262 }
1263 return rv;
1264}

Callers 2

UdpReceiveMessageFunction · 0.85
TcpReceiveMessageFunction · 0.85

Calls 12

AlarmShowFunction · 0.85
RunProgFunction · 0.85
WriteToLogErrorFunction · 0.85
FormatLastError2Function · 0.85
MatchMethod · 0.80
FormatMethod · 0.80
PlayMethod · 0.80
GetSoundFileNameMethod · 0.80
ToStringMethod · 0.80
GetMethod · 0.45
GetFileNameMethod · 0.45
SaveMethod · 0.45

Tested by

no test coverage detected