Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jbroadway/analog

PHP logging library that is highly extendable and simple to use.
https://github.com/jbroadway/analog

amon amon2 analog apprise chrome-logger error-monitoring errors firephp gelf logger logging mongodb monitoring php psr-3 stderr syslog

Last synced: 2 days ago
JSON representation

PHP logging library that is highly extendable and simple to use.

Awesome Lists containing this project

README

        

# Analog - Minimal PHP logging library

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/jbroadway/analog/ci.yml?branch=master)
![GitHub](https://img.shields.io/github/license/jbroadway/analog)
![Packagist Version](https://img.shields.io/packagist/v/analog/analog)
![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/analog/analog)
![Packagist Downloads](https://img.shields.io/packagist/dt/analog/analog)

A minimal PHP logging package based on the idea of using closures
for configurability and extensibility. It functions as a static class, but you can
completely control the writing of log messages through a closure function
(aka [anonymous functions](http://ca3.php.net/manual/en/functions.anonymous.php)),
or use the `Analog\Logger` wrapper that implements the
[PSR-3 specification](https://www.php-fig.org/psr/psr-3/).

## Installation

Install the latest version with:

```bash
$ composer require analog/analog
```

## Usage

### Basic Usage

```php
handler (Variable::init ($log));

$logger->alert ('Things are really happening right now!');

// With context
$logger->debug ('Testing {0}:{1}', [__FILE__, __LINE__]);

var_dump ($log);
```

### Usage with a custom handler

```php
mydb->log->insert ($info);
});

// Log an alert
Analog::log ('The sky is falling!', Analog::ALERT);

// Log some debug info
Analog::log ('Debugging info', Analog::DEBUG);
```

### Usage without composer

Analog uses a simple autoloader internally, so if you don't have access to [composer](https://getcomposer.org/) you can clone this repository and include it like this:

```php
What about Analog, the logfile analyzer? Well, since it hasn't been updated
> since 2004, I think it's safe to call a single-file PHP logging class the
> same thing without it being considered stepping on toes :)