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

Debugger: Logpoint name #896

Merged
merged 6 commits into from
Feb 13, 2018
Merged
Changes from all commits
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
25 changes: 22 additions & 3 deletions src/Debugger/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class Agent
use BatchDaemonTrait;
use SysvTrait;

const DEFAULT_LOGPOINT_LOG_NAME = 'debugger_logpoints';
const DEFAULT_APP_ENGINE_LOG_NAME = 'appengine.googleapis.com%2Frequest_log';

/**
* @var Debuggee
*/
Expand Down Expand Up @@ -167,7 +170,7 @@ public function __construct(array $options = [])
'snapshotId' => $breakpoint->id(),
'condition' => $breakpoint->condition(),
'expressions' => $breakpoint->expressions(),
'callback' => [$this->logger, 'log'],
'callback' => [$this, 'handleLogpoint'],
'sourceRoot' => $this->sourceRoot
]
);
Expand Down Expand Up @@ -202,6 +205,20 @@ public function handleSnapshot(array $snapshot)
}
}

/**
* Callback for reporting a logpoint.
*
* @access private
* @param mixed $level
* @param string $message
* @param array $context
* @return void
*/
public function handleLogpoint($level, $message, array $context = [])
{
$this->logger->log($level, "LOGPOINT: $message", $context);
}

/**
* Callback for batch runner to report a breakpoint.
*
Expand Down Expand Up @@ -245,8 +262,10 @@ private function defaultDebuggee()

private function defaultLogger()
{
$client = new LoggingClient();
return $client->psrBatchLogger('logpoints');
$logName = isset($server['GAE_SERVICE'])
? self::DEFAULT_APP_ENGINE_LOG_NAME
: self::DEFAULT_LOGPOINT_LOG_NAME;
return LoggingClient::psrBatchLogger($logName);
}

private function invalidateOpcache($breakpoint)
Expand Down