Skip to content

Commit

Permalink
inability to open telemeh log shall not be fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Jul 26, 2017
1 parent 975a67e commit f5d52c5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ int wmain(int argc, wchar_t *wargv[])
int flag;

unsigned int interval_id;
char telemeh_inited = 0;

for (; (flag = parse_flag(argv[argi])) != NOT_A_FLAG; ++argi) {
switch (flag) {
Expand Down Expand Up @@ -215,8 +216,12 @@ int wmain(int argc, wchar_t *wargv[])
getpid()
#endif
);
MVM_telemetry_init(fopen(path, "w"));
interval_id = MVM_telemetry_interval_start(0, "moarvm startup");
FILE *fp = fopen(path, "w");
if (fp) {
MVM_telemetry_init(fp);
telemeh_inited = 1;
interval_id = MVM_telemetry_interval_start(0, "moarvm startup");
}
}
#endif

Expand Down Expand Up @@ -246,7 +251,7 @@ int wmain(int argc, wchar_t *wargv[])
if (dump) MVM_vm_dump_file(instance, input_file);
else MVM_vm_run_file(instance, input_file);

if (getenv("MVM_TELEMETRY_LOG")) {
if (getenv("MVM_TELEMETRY_LOG") && telemeh_inited) {
MVM_telemetry_interval_stop(0, interval_id, "moarvm teardown");
MVM_telemetry_finish();
}
Expand Down

0 comments on commit f5d52c5

Please sign in to comment.