Dead simple centralized logging.

v0.3.4 2024-03-05 07:33 UTC

This package is not auto-updated.

Last update: 2024-10-29 10:54:15 UTC


README

Pile

Dead simple centralized logging.

Installation

You can install Pile using composer:

php composer.phar create-project bloatless/pile [my-pile-instance-name]
  • Point your virtual host document root to the public directory and rewrite ald requests to the index.php file.
  • Make sure the logs folder is writeable.
  • Create a new MySQL database using the db_stucture.sql file.
  • Adjust database configuration, api-keys and user-accounts in the config/config.php file.

Documentation

Log message structure

The general structure of a log message to be send to the Pile API should be as follows:

ยน = field is required

Log levels

Valid log level codes are:

Sending logs to your Pile instance

Using HTTP REST API

Log messages can be send to your Pile instance using a simple post request:

POST https://pile.yourdomain.com/api/v1/log
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
X-API-Key: 123123123

{
    "data": {
        "type": "log",
        "attributes": {
            "source": "MyProjectName",
            "message": "Some error occoured",
            "context": {
                "exception": {
                    "class": "My\\Fancy\\Classname",
                    "message": "Invalid value",
                    "code": "42",
                    "file": "\/framework\/src\/Foo\/Bar\/Classname.php:1337"
                }
            },
            "level": 400,
            "level_name": "ERROR",
            "channel": "dev",
            "datetime": "2019-11-05 17:44:26",
            "extra": []
        }
    }
} 

Be sure to include an API key within the request header.

Using Monolog Handler

If you are using Monolog in your project you can also use the MonoPile package which provides a handler and formatter for Monolog to easily send error-logs to your Pile instance.

License

MIT