2017 © Pedro Peláez
 

library logentries

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

image

cbschuld/logentries

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

  • Monday, June 19, 2017
  • by cbschuld
  • Repository
  • 1 Watchers
  • 1 Stars
  • 16,961 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

LogEntries

Build Status, (*1)

A LogEntries specific logging class by Chris Schuld for logging information to LogEntries, (*2)

About

LogEntries is an easy-to-use PHP PSR-3 compliant logging class used to log information to the LogEntries SaaS application., (*3)

Installation

Composer

From the Command Line:, (*4)

composer require cbschuld/LogEntries:1.*

In your composer.json:, (*5)

``` json { "require": { "cbschuld/LogEntries": "1.*" } }, (*6)


## Basic Usage ``` php <?php use cbschuld\LogEntries; require "vendor/autoload.php"; $token = "2bfbea1e-10c3-4419-bdad-7e6435882e1f"; // your LogEntries token (sample from docs) $log = LogEntries::getLogger($token,true,true); // create persistent SSL-based connection $log->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), (*7)

``` php <?php, (*8)

use cbschuld\LogEntries;, (*9)

require "vendor/autoload.php"; $token = "2bfbea1e-10c3-4419-bdad-7e6435882e1f"; // your LogEntries token (sample from docs) $jsonInfo = ["json"=>true,"example"=>"yes","works"=>true];, (*10)

$log = LogEntries::getLogger($token,true,true); // create persistent SSL-based connection $log->info(["status"=>"ok","example"=>"with json messages"]); $log->notice($jsonInfo);, (*11)


You can also create a non-static instantiation for dependency injection or multiple log token usage ``` php <?php use cbschuld\LogEntries; require "vendor/autoload.php"; $token = "2bfbea1e-10c3-4419-bdad-7e6435882e1f"; // your LogEntries token (sample from docs) $jsonInfo = ["json"=>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., (*12)

Here is a sample usage:, (*13)

``` php <?php, (*14)

use cbschuld\LogEntries; use cbschuld\LogEntriesWriter;, (*15)

class WriterTest extends LogEntriesWriter { // always add the hostname public function log($message,$isJson=false) { if($isJson) { $json = json_decode($message,true); $json["hostname"] = gethostname(); $message = json_encode($json); } else { $hostname = gethostname(); $message .= " hostname={$hostname}"; } return $message; } }, (*16)

$writer = new WriterTest();, (*17)

$json = array( "datetime" => new \DateTime("now"), "status" => "ok", ); $log = new LogEntries("MYTOKEN",true,true); $log->addWriter($writer); $log->info($json);, (*18)

```, (*19)

PSR-3 Compliant

LogEntries is PHP PSR-3 compliant. This means it implements the Psr\Log\LoggerInterface., (*20)

See Here for the interface definition., (*21)

License

The MIT License, (*22)

Copyright (c) 2015 Chris Schuld chris@chrisschuld.com, (*23)

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:, (*24)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*25)

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., (*26)

The Versions

19/06 2017

dev-master

9999999-dev

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

  Sources   Download

MIT

The Requires

 

The Development Requires

logging

22/05 2017

1.0.4

1.0.4.0

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

  Sources   Download

MIT

The Requires

 

The Development Requires

logging

05/09 2015

1.0.3

1.0.3.0

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

  Sources   Download

MIT

The Requires

 

The Development Requires

logging

31/08 2015

1.0.2

1.0.2.0

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

  Sources   Download

MIT

The Requires

 

The Development Requires

logging

31/08 2015

1.0.1

1.0.1.0

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

  Sources   Download

MIT

The Requires

 

The Development Requires

logging

31/08 2015

1.0

1.0.0.0

A PHP PSR-3 compliant logging class for LogEntries service (https://logentries.com/)

  Sources   Download

MIT

The Requires

 

The Development Requires

logging