apix / log Goto Github PK
View Code? Open in Web Editor NEWA thin (and fast) PSR-3 logger.
License: Other
A thin (and fast) PSR-3 logger.
License: Other
I really like how light and simple it is in contrast to Monolog.
Hey =)
I was searching for PSR-3 loggers and I found yours. I would like to know if this is a WIP or ready to use. I did not try it out yet, but by reading the following code I concluded that the email class is still a WIP. Is it?
https//github.com/frqnck/apix-log/blob/master/src/Logger/Mail.php#L22
It seems that the write
method is the same as the ErrorLog, so it do not actually send an email.
Cheers!
Python does this really well:
https://docs.python.org/2/library/logging.html#formatter-objects
It would be nice to be able to change the output format of the logger without having to create a subclass of the LogFormatter, which really looks like its geared to providing output that is significantly different - e.g. the Json example in the test case. But, for example, changing the default output to just the message as opposed to a date prefix doesn't seem like it should require writing a new class.
Hi,
first of all, great logger!
When I merge two loggers with different separators the merged logger has it's own separator instead of keeping the ones I set before.
$streamFormatter = new LogFormatter();
$streamFormatter->separator = '|';
$streamLogger = new Logger\Stream('php://output');
$streamLogger->setLogFormatter($streamFormatter);
$streamLogger->info('stream');
$fileFormatter = new LogFormatter();
$fileFormatter->separator = '#';
$fileLogger = new Logger\File('logs/log_'.date('Y-m-d').'.log');
$fileLogger->setLogFormatter($fileFormatter);
$fileLogger->info('file');
$mergedLogger = new Logger(array($streamLogger, $fileLogger));
$mergedLogger->info('merged');
In this example the output in screen is:
"stream|merged
"
and in the file:
"file#merged
"
when I expected
"stream|merged|"
and
"file#merged#"
Is this a bug or a feature?
Thanks in advance
Hey Franck,
Did some speed tests comparing Apix vs. Monolog, it turns out in deferred mode, the speed gains are huge.
-----------------------------------
platform : WINNT x64
php version : 8.1.4
xdebug : on
memory limit : 512M
max execution : 0
time per iteration : 20ms
iterations : 250
-----------------------------------
---------------------------------------------------------------
0 : logger_monolog logger_apix
mean : 25 1430 +5564.1%
median : 18 1756 +9934.3%
mode : 3 2013 +67000.0%
minimum : 1 28 +2700.0%
maximum : 73 2183 +2890.4%
quartile 1 : 5 750 +14900.0%
quartile 3 : 51 1979 +3780.4%
IQ range : 46 1229 +2571.7%
std deviation : 21 654 +2941.1%
normality : 30.7% 30.7%
---------------------------------------------------------------
And respective code
$file = new Apix\Log\Logger\File('log_apix.log');
$file
// intercept logs that are >= `warning`
->setMinLevel('warning')
// don't propagate to further buckets
->setCascading(true)
// postpone/accumulate logs processing
->setDeferred(true);
$log = new Apix\Log\Logger([$file]);
$stdout = new Apix\Log\Logger\Stream('php://stdout', 'a');
$stdout
// intercept logs that are >= `warning`
->setMinLevel('warning')
// don't propagate to further buckets
->setCascading(true)
// postpone/accumulate logs processing
->setDeferred(true);
$log->add($stdout);
while (microtime(true) < $time_limit) {
$log->warning('test');
++$iterations;
}
$log = new Monolog\Logger('test');
$log->pushHandler(new Monolog\Handler\StreamHandler('log_monolog.log', Monolog\Level::Warning));
// log to stdout
$log->pushHandler(new Monolog\Handler\StreamHandler('php://stdout', Monolog\Level::Warning));
while (microtime(true) < $time_limit) {
$log->warning('test');
++$iterations;
}
Hi @frqnck
I intend to use this library to write logs to files in JSON format, then have Fluentd / Fluentbit tail these files for further processing.
I'd be interested in the "deferred" option to avoid writing to a file on disk all throughout script execution (seems cleaner to me to make one big write at the end).
However, the current implementation in AbstractLogger, method __destruct seems to just take all messages (strings), throw away the context, and write a single NOTICE entry in the log.
Why is that? I would have expected the deferred method to just process the backlog of log entries and write() them one by one.
Should you maybe clarify the way it works in the README?
Also, is there any technical reason for the "final" keyword on __destruct in AbstractLogger?
Thanks
When I try to install ^1.2.2
of this together with anything that requires psr/log >= 2.0
, Composer fails. This is because even the last tagged version does not allow psr/log
2 and 3. These changes are present on master
, however. So all that needs to be done is adding a tag.
Please ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.