Realtime monitoring, for your entire business. A LogSnag PHP SDK.
To install the SDK you will need to be using Composer in your project. To install it please see the composer docs.
This is the "core" SDK, meaning that all the core logic and models are here.
If you are happy with using your own HTTP client, install the SDK
like: joppedc/logsnag-php-sdk
composer require joppedc/logsnag-php-sdk
This package (joppedc/logsnag-php-sdk
) is not tied to any specific library that sends HTTP messages. Instead,
it uses Httplug to let users choose whichever
PSR-7 implementation and HTTP client they want to use.
If you just want to get started quickly you should run the following command:
composer require joppedc/logsnag-php-sdk php-http/curl-client
This will install the library itself along with an HTTP client adapter that uses cURL as transport method (provided by Httplug). You do not have to use those packages if you do not want to. The SDK does not care about which transport method you want to use because it's an implementation detail of your application.
new JoppeDc\LogsnagPhpSdk\Client("your_secret_key");
$payload = new JoppeDc\LogsnagPhpSdk\Contracts\LogPayload(
'project_name',
'channel_name',
'event_name'
);
$payload->setDescription('test-description');
$payload->setTags(['tag' => 'tag value']);
$payload->setIcon('😀');
$log = $this->client->createLog($payload);
$payload = new JoppeDc\LogsnagPhpSdk\Contracts\InsightPayload(
'project_name',
'title',
5
);
$payload->setIcon('😀');
$insight = $this->client->createInsight($payload);
$payload = new JoppeDc\LogsnagPhpSdk\Contracts\MutateInsightPayload(
'project_name',
'title',
-5
);
$payload->setIcon('😀');
$insight = $this->client->mutateInsight($payload);