Skip to content

Commit f91fff5

Browse files
committed
Merge branch 'release/0.9.2'
2 parents 1db77ee + 9e2cb84 commit f91fff5

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

.version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"strategy": "semver",
33
"major": 0,
44
"minor": 9,
5-
"patch": 1,
5+
"patch": 2,
66
"build": 0
77
}

VERSIONLOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## 0.9.2 2026-01-02
2+
13
## 0.9.1 2025-12-11
24
* **Nightwatch destination now uses system abstractions** - Refactored to use `IHttpClient` interface instead of direct curl calls
35
* Added `neuron-php/core` 0.8.* dependency for system abstractions

src/Log/Destination/File.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ public function open( array $params ) : bool
5151
{
5252
$this->_name = $this->buildFileName( $params[ 'file_name' ] );
5353

54+
// Create directory if it doesn't exist
55+
$directory = dirname( $this->_name );
56+
if( !is_dir( $directory ) )
57+
{
58+
@mkdir( $directory, 0755, true );
59+
}
60+
5461
$this->_file = @fopen( $this->_name, 'a' );
5562

5663
if( !$this->_file )

tests/Log/Destination/FileTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,33 @@ public function testWriteWithInvalidFileHandle()
6262
// Test passes if no exception is thrown
6363
$this->assertTrue( true );
6464
}
65+
66+
public function testOpenCreatesDirectoryIfNotExists()
67+
{
68+
$tempDir = sys_get_temp_dir() . '/neuron_log_test_' . uniqid();
69+
$logFile = $tempDir . '/logs/test.log';
70+
71+
$File = new File( new CSV() );
72+
73+
// Directory should not exist yet
74+
$this->assertFalse( is_dir( dirname( $logFile ) ) );
75+
76+
// Open should succeed and create directory
77+
$Pass = $File->open(
78+
[
79+
'file_name' => $logFile
80+
]
81+
);
82+
83+
$this->assertTrue( $Pass );
84+
$this->assertTrue( is_dir( dirname( $logFile ) ) );
85+
$this->assertTrue( file_exists( $logFile ) );
86+
87+
$File->close();
88+
89+
// Clean up
90+
@unlink( $logFile );
91+
@rmdir( dirname( $logFile ) );
92+
@rmdir( $tempDir );
93+
}
6594
}

0 commit comments

Comments
 (0)