Skip to content

Commit e045013

Browse files
committed
Fix double logging
Signed-off-by: JR <[email protected]>
1 parent c37ec1b commit e045013

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Main.cc

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int cmd_argc;
8282
char** cmd_argv;
8383
static const char* log_filename = nullptr;
8484
static const char* metrics_filename = nullptr;
85-
static std::unique_ptr<std::set<std::string>> commands;
85+
static std::unique_ptr<std::set<std::string>> commands, sta_commands;
8686
static bool no_settings = false;
8787
static bool minimize = false;
8888

@@ -393,7 +393,7 @@ static int TraceTclCommand(
393393
Tcl_Obj *fullName = Tcl_NewObj();
394394
Tcl_GetCommandFullName(interp, commandToken, fullName);
395395
string fullName_str = Tcl_GetString(fullName);
396-
if(fullName_str.compare(0, 7, "::sta::")!=0){
396+
if(fullName_str.compare(0, 7, "::sta::")==0||!sta_commands->count(Tcl_GetString(objv[0]))){
397397
logger->report("[CMD] "+cmd_str);
398398
}
399399
}
@@ -461,6 +461,7 @@ static int tclAppInit(int& argc,
461461
}
462462

463463
commands = std::make_unique<std::set<std::string>>();
464+
sta_commands = std::make_unique<std::set<std::string>>();
464465
if (Tcl_Eval(interp, "array names sta::cmd_args") == TCL_OK) {
465466
Tcl_Obj* cmd_names = Tcl_GetObjResult(interp);
466467
int cmd_size;
@@ -472,6 +473,18 @@ static int tclAppInit(int& argc,
472473
}
473474
}
474475
}
476+
if (Tcl_Eval(interp, "info commands ::sta::*") == TCL_OK) {
477+
Tcl_Obj* cmd_names = Tcl_GetObjResult(interp);
478+
int cmd_size;
479+
Tcl_Obj** cmds_objs;
480+
if (Tcl_ListObjGetElements(interp, cmd_names, &cmd_size, &cmds_objs)
481+
== TCL_OK) {
482+
for (int i = 0; i < cmd_size; i++) {
483+
string str = Tcl_GetString(cmds_objs[i]);
484+
sta_commands->insert(string(str.begin()+7, str.end()));
485+
}
486+
}
487+
}
475488
Tcl_CreateObjTrace(
476489
interp,
477490
0,

0 commit comments

Comments
 (0)