Skip to content

Commit

Permalink
Merge 7892dca into 530ba8f
Browse files Browse the repository at this point in the history
  • Loading branch information
EricTendian committed Nov 19, 2021
2 parents 530ba8f + 7892dca commit f098365
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Emitters/FileEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ class FileEmitter extends Emitter {
* @param int|float|null $timeout
* @param int|null $buffer_size
* @param bool|null $debug
* @param string|null $log_dir
*/
public function __construct($uri, $protocol = NULL, $type = NULL, $workers = NULL, $timeout = NULL, $buffer_size = NULL, $debug = false) {
public function __construct($uri, $protocol = NULL, $type = NULL, $workers = NULL, $timeout = NULL, $buffer_size = NULL, $debug = false, $log_dir = NULL) {

// Set error handler to catch warnings
$this->warning_handler();
Expand All @@ -60,7 +61,7 @@ public function __construct($uri, $protocol = NULL, $type = NULL, $workers = NUL

$this->type = $this->getRequestType($type);
$this->url = $this->getCollectorUrl($this->type, $uri, $protocol);
$this->log_dir = $this->worker_root.self::WORKER_FOLDER;
$this->log_dir = $log_dir ?: $this->worker_root.self::WORKER_FOLDER;

// Initilize the event log file
$this->log_file = $this->initLogFile();
Expand Down
7 changes: 7 additions & 0 deletions tests/tests/EmitterTests/FileEmitterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,11 @@ public function testReturnFunctions() {
$this->assertEquals($root_dir."/temp/w1/",
$paths[1]);
}

public function testLogDirOverridden() {
$log_dir = "/tmp/snowplow/";
$emitter = new FileEmitter($this->uri, false, "POST", 3, 3, 100, false, $log_dir);

$this->assertEquals($log_dir, $emitter->returnLogDir());
}
}

0 comments on commit f098365

Please sign in to comment.