Download the PHP package outsourced/log-sdk without Composer
On this page you can find all versions of the php package outsourced/log-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download outsourced/log-sdk
More information about outsourced/log-sdk
Files in outsourced/log-sdk
Informations about the package log-sdk
Outsourced PHP SDK
PHP SDK for Outsourced
Installation
composer require outsourced/sdk
Usage
To do any communication with outsourced API, you have to create an Outsourced instance. We provide HttpOutsourced class. By default, this class uses Guzzle as a http client, but you can use other clients, if you want to.
Single Log
Send single log to outsourced server by calling logSingle method of HttpOutsourced instance.
Batch log
Send logs in batch to outsourced server by calling logBatch method of HttpOutsourced instance.
Additional Context for All Logs
You may want to add some addition information to all your logs without the need to specify this context when calling logSingle or logBatch. You can define global context when creating HttpOutsourced instance. Just add logging.context index, to config array, with your values.
Verify Permissions
Send permission verification request to outsourced server by calling verifyPermissions method of HttpOutsourced instance.
Custom HttpClient
Your custom client have to implement Psr\Http\Client\ClientInterface interface. Then you can use instance of your class as a first parameter of make static method of HttpOutsourced.
Logging
Every log consists of 2 required properties and one optional property
- level - should be one of these 8 options
debug,info,notice,warning,error,critical,alert,emergency - message - description of logged event
- context *optional - additional logged values
Default Context
If you create HttpOutsourced instance by calling make or makeWithGuzzle you will automaticaly receive these values in every log context:
- url - current URL
- method - current request method
- ip - user IP
- user_agent - user agent name
- server - server software
- runtime - language + version (in this case php + php_version)
LoggerInterface
To use this SDK as a PSR-3 logger you can use our implementation of LoggerInterface, OutsourcedLogger.
All versions of log-sdk with dependencies
guzzlehttp/guzzle Version ^7.2
guzzlehttp/psr7 Version ^1.7
psr/http-client Version ^1.0
psr/log Version ^1.0