All Projects → apix → log

apix / log

Licence: other
A thin (and fast) PSR-3 logger.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to log

Screenshot Stream
Capture screenshot of a website and return it as a stream
Stars: ✭ 228 (+406.67%)
Mutual labels:  stream
Ttrpc
GRPC for low-memory environments
Stars: ✭ 236 (+424.44%)
Mutual labels:  stream
streamplify
Java 8 combinatorics-related streams and other utilities
Stars: ✭ 40 (-11.11%)
Mutual labels:  stream
Paguro
Generic, Null-safe, Immutable Collections and Functional Transformations for the JVM
Stars: ✭ 231 (+413.33%)
Mutual labels:  stream
Subtitle.js
Stream-based library for parsing and manipulating subtitle files
Stars: ✭ 234 (+420%)
Mutual labels:  stream
chump
Pushover.net client for Node.js
Stars: ✭ 19 (-57.78%)
Mutual labels:  pushover
Firebase Esp8266
ESP8266 Firebase RTDB Arduino Library
Stars: ✭ 228 (+406.67%)
Mutual labels:  stream
missive
Fast, lightweight library for encoding and decoding JSON messages over streams.
Stars: ✭ 16 (-64.44%)
Mutual labels:  stream
Multistream
A stream that emits multiple other streams one after another (streams3)
Stars: ✭ 237 (+426.67%)
Mutual labels:  stream
create-music-stream
Creates a PCM 16 bit Little Endian Stream from a mp3 file or youtube video
Stars: ✭ 21 (-53.33%)
Mutual labels:  stream
Tributary
Streaming reactive and dataflow graphs in Python
Stars: ✭ 231 (+413.33%)
Mutual labels:  stream
Azure Event Hubs
☁️ Cloud-scale telemetry ingestion from any stream of data with Azure Event Hubs
Stars: ✭ 233 (+417.78%)
Mutual labels:  stream
pycameresp
Motion detection with image notification for Esp32CAM and Esp32 flasher with GUI based on esptool.py.
Stars: ✭ 40 (-11.11%)
Mutual labels:  pushover
Zipson
JSON parse and stringify with compression
Stars: ✭ 229 (+408.89%)
Mutual labels:  stream
mock-hls-server
Fake a live/event HLS stream from a VOD one. Useful for testing. Supports looping.
Stars: ✭ 61 (+35.56%)
Mutual labels:  stream
Twitch Js
A community-centric, community-supported version of tmi.js
Stars: ✭ 225 (+400%)
Mutual labels:  stream
magister-calendar
📅 Automatically plan your Magister appointments in your Google calendar.
Stars: ✭ 12 (-73.33%)
Mutual labels:  pushover
matroska-subtitles
💬 Streaming parser for embedded .mkv subtitles.
Stars: ✭ 40 (-11.11%)
Mutual labels:  stream
Commander
Arduino Command Line Utility
Stars: ✭ 20 (-55.56%)
Mutual labels:  stream
sox-stream
📣 A stream-friendly wrapper around SoX
Stars: ✭ 50 (+11.11%)
Mutual labels:  stream

APIx Log, very thin PSR-3 logger Build Status

Latest Stable Version Total Downloads Build Status Code Quality Code Coverage License

Minimalist and fast PSR-3 compliant logger.

  • Light, come out-of-the-box bundle with wrappers for:
    • ErrorLog, File, Mail, Sapi ~ built around the error_log() function,
    • Runtime ~ as an Array/ArrayObject wrapper, and Nil ~ as Null wrapper,
    • Stream ~ logs are sent to sockets, local and remote files, filters and other similar resources (default to standard output bypassing output buffering).
  • Extendable, additional logging backends are available:
  • Clean API, see the LoggerInterface and the LogFormatterInterface.
  • 100% Unit tested and compliant with PSR0, PSR1 and PSR2.
  • Continuously integrated against 7.0, 8.x, and HHVM (use ^1.1 for older PHP versions).
  • Available as a Composer and as a PEAR package.

Feel free to comment, send pull requests and patches...

🆕 Log dispatch can be postponed/accumulated using setDeferred().

Basic usage ~ standalone

$urgent_logger = new Apix\Log\Logger\Mail('[email protected]');
$urgent_logger->setMinLevel('critical');   // catch logs >= to `critical`

This simple logger is now set to intercept critical, alert and emergency logs.

To log an event, use:

$urgent_logger->alert('Running out of {stuff}', ['stuff' => 'beers']);

Advanced usage ~ multi-logs dispatcher

Lets create an additional logger with purpose of catching log entries that have a severity level of warning or more -- see the log levels for the order.

$app_logger = new Apix\Log\Logger\File('/var/log/apix_app.log');
$app_logger->setMinLevel('warning')  // intercept logs that are >= `warning`
           ->setCascading(false)     // don't propagate to further buckets
           ->setDeferred(true);      // postpone/accumulate logs processing

setCascading() was set to false (default is true) so the entries caught here won't continue downstream past that particular log bucket. setDeferred() was set to true (default is false) so processing happen on __destruct (end of script generally) rather than on the fly.

Now, lets create a main logger object and inject the two previous loggers.

// The main logger object (injecting an array of loggers)
$logger = new Apix\Log\Logger( array($urgent_logger, $app_logger) );

Lets create an additional logger -- just for development/debug purposes.

if(DEBUG) {
  // Bucket for the remaining logs -- i.e. `notice`, `info` and `debug`
  $dev_logger = new Apix\Log\Logger\Stream(); // default to screen without output buffer
  // $dev_logger = new Logger\File('/tmp/apix_debug.log'); 
  $dev_logger->setMinLevel('debug');

  $logger->add($dev_logger);   		// another way to inject a log bucket
}

Finally, lets push some log entries:

$e = new \Exception('Boo!');

// handled by both $urgent_logger & $app_logger
$logger->critical('OMG saw {bad-exception}', [ 'bad-exception' => $e ]);

// handled by $app_logger
$logger->error($e); // push an object (or array) directly

// handled by $dev_logger
$logger->info('Testing a var {my_var}', array('my_var' => array(...)));

Log levels

The eight RFC 5424 levels of logs are supported, in cascading order:

Severity Description
Emergency System level failure (not application level)
Alert Failure that requires immediate attention
Critical Serious failure at the application level
Error Runtime errors, used to log unhandled exceptions
Warning May indicate that an error will occur if action is not taken
Notice Events that are unusual but not error conditions
Info Normal operational messages (no action required)
Debug Verbose info useful to developers for debugging purposes (default)

Installation

Install the current major version using Composer with (recommended)

$ composer require apix/log:1.2.*

Or install the latest stable version with

$ composer require apix/log

License

APIx Log is licensed under the New BSD license -- see the LICENSE.txt for the full license details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].