https://github.com/cbschuld/logentries
LogEntries for PHP - an easy-to-use PHP PSR-3 compliant logging class used to log information to the LogEntries SaaS application.
https://github.com/cbschuld/logentries
logentries php
Last synced: 2 months ago
JSON representation
LogEntries for PHP - an easy-to-use PHP PSR-3 compliant logging class used to log information to the LogEntries SaaS application.
- Host: GitHub
- URL: https://github.com/cbschuld/logentries
- Owner: cbschuld
- License: mit
- Created: 2015-08-29T16:47:05.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-06-24T16:14:34.000Z (about 5 years ago)
- Last Synced: 2025-03-26T02:03:42.468Z (3 months ago)
- Topics: logentries, php
- Language: PHP
- Homepage:
- Size: 20.5 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LogEntries
[](https://travis-ci.org/cbschuld/logentries)A LogEntries specific logging class by [Chris Schuld](http://chrisschuld.com/) for logging information to [LogEntries](https://logentries.com)
## About
LogEntries is an easy-to-use PHP [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
compliant logging class used to log information to the [LogEntries](https://logentries.com) SaaS application.## Installation
### Composer
From the Command Line:
```
composer require cbschuld/LogEntries:1.*
```In your `composer.json`:
``` json
{
"require": {
"cbschuld/LogEntries": "1.*"
}
}
```## Basic Usage
``` php
info("some information");
$log->notice(json_encode(["status"=>"ok","message"=>"send some json"]));```
## Advanced Usage
You can send all of the logging functions either a string (PSR-3), encoded JSON (PSR-3)
or an array which will be encoded into JSON (not PSR-3 but available)``` php
true,"example"=>"yes","works"=>true];$log = LogEntries::getLogger($token,true,true); // create persistent SSL-based connection
$log->info(["status"=>"ok","example"=>"with json messages"]);
$log->notice($jsonInfo);```
You can also create a non-static instantiation for dependency injection or multiple log token usage
``` php
true,"example"=>"yes","works"=>true];$log = new LogEntries($token,true,true); // create persistent SSL-based connection
$log->info(["status"=>"ok","example"=>"with json messages"]);
$log->notice($jsonInfo);$token2 = "2bfbea1e-10c3-4419-bdad-7e6435882e1f"; // your LogEntries token (sample from docs)
$log2 = new LogEntries($token2,true,true); // create persistent SSL-based connection
$log2->info(["status"=>"ok","example"=>"with json messages","from"=>"log2"]);
$log2->notice($jsonInfo);```
## Middleware (Writer)
Using a LogEntriesWriter you can append log writing middleware into the log. The middleware is called before the log
is written to LogEntries. It allows for sensing for JSON or text. This allows you to append data from your
architecture into your logs.Here is a sample usage:
``` php
new \DateTime("now"),
"status" => "ok",
);
$log = new LogEntries("MYTOKEN",true,true);
$log->addWriter($writer);
$log->info($json);```
## PSR-3 Compliant
LogEntries is PHP [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
compliant. This means it implements the `Psr\Log\LoggerInterface`.[See Here for the interface definition.](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md#3-psrlogloggerinterface)
## License
The MIT License
Copyright (c) 2015 Chris Schuld
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.