diff --git a/src/Emitters/FileEmitter.php b/src/Emitters/FileEmitter.php index 11a497c..1f9f3a7 100644 --- a/src/Emitters/FileEmitter.php +++ b/src/Emitters/FileEmitter.php @@ -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(); @@ -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(); diff --git a/tests/tests/EmitterTests/FileEmitterTest.php b/tests/tests/EmitterTests/FileEmitterTest.php index b30bd5b..ba19231 100644 --- a/tests/tests/EmitterTests/FileEmitterTest.php +++ b/tests/tests/EmitterTests/FileEmitterTest.php @@ -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()); + } }