Skip to content

Commit 191ae89

Browse files
committed
added exception handler
1 parent b8a8e0f commit 191ae89

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/log.cxx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,20 @@ int main(int argc, char** argv)
202202
}
203203
}
204204

205-
InfoLogger theLog;
205+
std::unique_ptr<InfoLogger> theLog;
206+
try {
207+
theLog=std::make_unique<InfoLogger>();
208+
}
209+
catch(int err) {
210+
printf("Failed to initialize infoLogger: exception %d\n",err);
211+
return -1;
212+
}
213+
206214

207215
// additionnal args = messages to send
208216
int i;
209217
for (i = optind; i < argc; i++) {
210-
theLog.log(msgOptions, msgContext, "%s", argv[i]);
218+
theLog->log(msgOptions, msgContext, "%s", argv[i]);
211219
}
212220

213221
// todo: catch exceptions
@@ -227,7 +235,7 @@ int main(int argc, char** argv)
227235
break;
228236
}
229237
//infoLogger_msg_xt(UNDEFINED_STRING,UNDEFINED_INT,UNDEFINED_INT,facility,severity,level,msg);
230-
theLog.log(msgOptions, msgContext, "%s", msg.c_str());
238+
theLog->log(msgOptions, msgContext, "%s", msg.c_str());
231239
}
232240
if (eof)
233241
break;

0 commit comments

Comments
 (0)