Last active
March 12, 2020 09:53
-
-
Save ojhaujjwal/fddd88f49e86cb80be382732a45058b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function createLogger($file)): Generator { | |
$f = fopen($file, 'a'); | |
while (true) { | |
$line = yield; | |
fwrite($f, $line. "\n"); | |
} | |
} | |
$log = createLogger('/path-to-log/file.log'); | |
$log->send("First"); | |
$log->send("Second"); | |
$log->send("Third"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment