empiredan commented on code in PR #1760:
URL:
https://github.com/apache/incubator-pegasus/pull/1760#discussion_r1423503910
##########
src/shell/commands/debugger.cpp:
##########
@@ -101,12 +104,28 @@ bool mlog_dump(command_executor *e, shell_context *sc,
arguments args)
return false;
}
}
- if (input.empty()) {
- fprintf(stderr, "ERROR: input is not specified\n");
+ if (plog_dir.empty()) {
+ fmt::print(stderr, "ERROR: 'input' is not specified\n");
return false;
}
- if (!dsn::utils::filesystem::directory_exists(input)) {
- fprintf(stderr, "ERROR: input %s is not a directory\n", input.c_str());
+ if (!dsn::utils::filesystem::directory_exists(plog_dir)) {
+ fmt::print(stderr, "ERROR: '{}' is not a directory\n", plog_dir);
+ return false;
+ }
+
+ char splitters[] = {'\\', '/', 0};
+ auto slog_dir_tmp = plog_dir;
+ std::string name =
+ dsn::utils::get_last_component(dirname((char *)slog_dir_tmp.c_str()),
splitters);
+ if (name.empty()) {
+ fmt::print(stderr, "ERROR: '{}' is not a valid slog directory\n",
plog_dir);
Review Comment:
```suggestion
fmt::print(stderr, "ERROR: '{}' is not a valid plog directory\n",
plog_dir);
```
##########
src/shell/commands/debugger.cpp:
##########
@@ -101,12 +104,28 @@ bool mlog_dump(command_executor *e, shell_context *sc,
arguments args)
return false;
}
}
- if (input.empty()) {
- fprintf(stderr, "ERROR: input is not specified\n");
+ if (plog_dir.empty()) {
+ fmt::print(stderr, "ERROR: 'input' is not specified\n");
return false;
}
- if (!dsn::utils::filesystem::directory_exists(input)) {
- fprintf(stderr, "ERROR: input %s is not a directory\n", input.c_str());
+ if (!dsn::utils::filesystem::directory_exists(plog_dir)) {
+ fmt::print(stderr, "ERROR: '{}' is not a directory\n", plog_dir);
+ return false;
+ }
+
+ char splitters[] = {'\\', '/', 0};
+ auto slog_dir_tmp = plog_dir;
+ std::string name =
+ dsn::utils::get_last_component(dirname((char *)slog_dir_tmp.c_str()),
splitters);
+ if (name.empty()) {
+ fmt::print(stderr, "ERROR: '{}' is not a valid slog directory\n",
plog_dir);
+ return false;
+ }
+
+ char app_type[128];
+ int32_t app_id, pidx;
+ if (3 != sscanf(name.c_str(), "%d.%d.%s", &app_id, &pidx, app_type)) {
+ fmt::print(stderr, "ERROR: '{}' is not a valid slog directory\n",
plog_dir);
Review Comment:
```suggestion
fmt::print(stderr, "ERROR: '{}' is not a valid plog directory\n",
plog_dir);
```
##########
src/shell/commands/debugger.cpp:
##########
@@ -101,12 +104,28 @@ bool mlog_dump(command_executor *e, shell_context *sc,
arguments args)
return false;
}
}
- if (input.empty()) {
- fprintf(stderr, "ERROR: input is not specified\n");
+ if (plog_dir.empty()) {
+ fmt::print(stderr, "ERROR: 'input' is not specified\n");
return false;
}
- if (!dsn::utils::filesystem::directory_exists(input)) {
- fprintf(stderr, "ERROR: input %s is not a directory\n", input.c_str());
+ if (!dsn::utils::filesystem::directory_exists(plog_dir)) {
+ fmt::print(stderr, "ERROR: '{}' is not a directory\n", plog_dir);
+ return false;
+ }
+
+ char splitters[] = {'\\', '/', 0};
+ auto slog_dir_tmp = plog_dir;
+ std::string name =
+ dsn::utils::get_last_component(dirname((char *)slog_dir_tmp.c_str()),
splitters);
Review Comment:
```suggestion
const auto replica_path = std::filesystem::path(plog_dir).parent_path();
const auto name = replica_path.filename().string();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]