Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fabric-Sync] Run interactive mode in Fabric-Admin by default #33455

Merged
merged 3 commits into from
May 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
allocate make a std::vector<const char*> and pass .data() of that vec…
…tor to commands.Run()
yufengwangca committed May 16, 2024
commit b662d53f8ea6d1bf06038c37c50f8e331cfd8346
Original file line number Diff line number Diff line change
@@ -62,18 +62,19 @@ void ClearLine()

void ENFORCE_FORMAT(3, 0) LoggingCallback(const char * module, uint8_t category, const char * msg, va_list args)
{
if (sLogFile == nullptr)
{
return;
}

uint64_t timeMs = chip::System::SystemClock().GetMonotonicMilliseconds64().count();
uint64_t seconds = timeMs / 1000;
uint64_t milliseconds = timeMs % 1000;

flockfile(sLogFile);

// Portable thread and process identifiers
auto pid = static_cast<unsigned long>(getpid());
auto tid = static_cast<unsigned long>(pthread_self());

fprintf(sLogFile, "[%llu.%06llu][%lu:%lu] CHIP:%s: ", static_cast<unsigned long long>(seconds),
static_cast<unsigned long long>(milliseconds), pid, tid, module);
fprintf(sLogFile, "[%llu.%06llu] CHIP:%s: ", static_cast<unsigned long long>(seconds),
static_cast<unsigned long long>(milliseconds), module);
vfprintf(sLogFile, msg, args);
fprintf(sLogFile, "\n");
fflush(sLogFile);
16 changes: 7 additions & 9 deletions examples/fabric-admin/main.cpp
Original file line number Diff line number Diff line change
@@ -41,16 +41,8 @@ int main(int argc, char * argv[])
// Insert "interactive" and "start" after the executable name
args.insert(args.begin() + 1, "interactive");
args.insert(args.begin() + 2, "start");

// Update argc and argv to reflect the new arguments
argc = static_cast<int>(args.size());
for (size_t i = 0; i < args.size(); ++i)
{
argv[i] = const_cast<char *>(args[i].c_str());
}
}

// const char * args[] = { argv[0], "interactive", "start" };
ExampleCredentialIssuerCommands credIssuerCommands;
Commands commands;

@@ -59,5 +51,11 @@ int main(int argc, char * argv[])
registerClusters(commands, &credIssuerCommands);
registerCommandsSubscriptions(commands, &credIssuerCommands);

return commands.Run(argc, argv);
std::vector<char *> c_args;
for (auto & arg : args)
{
c_args.push_back(const_cast<char *>(arg.c_str()));
}

return commands.Run(static_cast<int>(c_args.size()), c_args.data());
}