Should CodeIgniter\Log\FileHandler support [schema]://[path] |
Hi everyone,
I was wondering if the CodeIgniter\Log\FileHandler should support streaming to [schema]://[path] (eg. php://stdout)? Would love to work on a PR for this as I would really love to start contributing to CI4. (Picked up CI after many years and I must say that I love what you are doing and the direction you have taken) I have lots more ideas and suggestions, but I have to start somewhere.
I think a StreamHandler is the way to go. I'm curious about how do you see the "stream" being used?
(03-27-2020, 02:12 PM)dave friend Wrote: I think a StreamHandler is the way to go. I'm curious about how do you see the "stream" being used? Everything started with me having a Docker setup in which I collect the stdout from all containers and combine it to one (way of centralizing logs while developing). While looking at the source co of the FileHandler I came across this line: PHP Code: $filepath = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension; and realized that setting the path to "php://stdout" is not going to work, because the handler will always append the 'log-'... string as the file name. That is why there was a need for php://stdout. Looking at the PHP wrapper made me think if some other wrappers would need to be supported. Supporting zlib:// or even ssh2:// would also be handy. The thing with supporting other wrappers comes with a price and that would be lots of fs, network, ... IO. How can we optimize the IO mechanism in a way that we write just once to our configured path (eg. zip://./logs.zip#log_name.log)!? How about this... Logger->log writes to php://temp and the Logger class also registers a shutdown function that reads logs from php://temp and writes to all log handlers in the queue (making some decisions based on the level). Here is a simple example, to better explain my idea: PHP Code: <?php Edit: a+ mode would be more appropriate |
Welcome Guest, Not a member yet? Register Sign In |