joppedc/logsnag-php-sdk

An integration of the Logsnag API for PHP

v1.0.2 2023-04-09 10:42 UTC

This package is auto-updated.

Last update: 2024-04-15 13:00:39 UTC


README

LogSnag

Realtime monitoring, for your entire business. A LogSnag PHP SDK.

Latest Stable Version Test License

Unofficial PHP SDK

Getting started

Install

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.

Configuration

new JoppeDc\LogsnagPhpSdk\Client("your_secret_key");

Usage

Create new log event

$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);

Create new insight event

$payload = new JoppeDc\LogsnagPhpSdk\Contracts\InsightPayload(
    'project_name',
    'title',
    5
);

$payload->setIcon('😀');

$insight = $this->client->createInsight($payload);

Mutate an insight event

$payload = new JoppeDc\LogsnagPhpSdk\Contracts\MutateInsightPayload(
    'project_name',
    'title',
    -5
);

$payload->setIcon('😀');

$insight = $this->client->mutateInsight($payload);

Special thanks