Skip to content

Commit da370c0

Browse files
Nikhil Thomasmeta-codesync[bot]
authored andcommitted
Add --from CLI flag for caller identification logging
Summary: Add a `--from` CLI flag to hphpd so callers can identify themselves (e.g., "notebook X" or "script Y") in debugger usage logs. Reviewed By: mdko Differential Revision: D95228198 fbshipit-source-id: db465b4b8c00f31f54514b8d1c97e89b22bbde0f
1 parent 1f98dfd commit da370c0

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

hphp/runtime/base/program-functions.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,8 @@ static int execute_program_impl(int argc, char** argv) {
16151615
("debug-sandbox",
16161616
value<std::string>(&po.debugger_options.sandbox)->default_value("default"),
16171617
"initial sandbox to attach to when debugger is started")
1618+
("from", value<std::string>(&po.debugger_options.from),
1619+
"caller identifier for debugger usage logging")
16181620
("user,u", value<std::string>(&po.user),
16191621
"run server under this user account")
16201622
("file,f", value<std::string>(&po.file),

hphp/runtime/debugger/debugger_base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct DebuggerClientOptions {
3939
std::string user;
4040
std::string configFName;
4141
std::string fileName;
42+
std::string from;
4243
};
4344

4445
///////////////////////////////////////////////////////////////////////////////
@@ -234,6 +235,7 @@ struct DebuggerUsageLogger {
234235
virtual void clearClientInfo() {}
235236
virtual void setClientInfo(const std::string& /*username*/, uid_t /*uid*/,
236237
pid_t /*clientPid*/) {}
238+
virtual void setFrom(const std::string& /*from*/) {}
237239
virtual void
238240
log(const std::string& /*clientId*/, const std::string& /*mode*/,
239241
const std::string& /*sandboxId*/, const std::string& /*cmd*/,

hphp/runtime/debugger/debugger_client.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,9 @@ void DebuggerClient::init(const DebuggerClientOptions &options) {
761761
m_options.user = Process::GetCurrentUser();
762762
}
763763

764+
auto* logger = Debugger::GetUsageLogger();
765+
if (logger) logger->setFrom(options.from);
766+
764767
usageLogEvent("init");
765768

766769
loadConfig();

0 commit comments

Comments
 (0)