PHPackages                             partner-api/logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. partner-api/logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

partner-api/logger
==================

Partner API Logger SDK for PHP — send structured logs and metrics to the Partner API ingest service

v1.1.0(2mo ago)013↓100%MITPHPPHP ^8.1

Since Mar 5Pushed 2mo agoCompare

[ Source](https://github.com/okjake/partner-api-logger-php)[ Packagist](https://packagist.org/packages/partner-api/logger)[ RSS](/packages/partner-api-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Partner API Logger SDK for PHP
==============================

[](#partner-api-logger-sdk-for-php)

Send structured logs and metrics to the Partner API ingest service.

Requirements
------------

[](#requirements)

- PHP 8.1+

Installation
------------

[](#installation)

```
composer require partner-api/logger
```

Laravel Setup
-------------

[](#laravel-setup)

The package auto-discovers in Laravel. Publish the config file:

```
php artisan vendor:publish --tag=partner-logger-config
```

Add your credentials to `.env`:

```
PARTNER_API_TENANT_TOKEN=tenant_live_xxxxxxxxxxxx
PARTNER_API_BASE_URL=https://ingest.partnerapi.com
```

### Using the Facade

[](#using-the-facade)

```
use PartnerApi\Logger\Laravel\Facades\PartnerLogger;

PartnerLogger::info($apiKey, 'Order created', ['orderId' => $order->id]);
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use PartnerApi\Logger\Logger;

class OrderController extends Controller
{
    public function store(Request $request, Logger $logger)
    {
        // ...
        $logger->info($apiKey, 'Order created', ['orderId' => $order->id]);
    }
}
```

Standalone Usage (without Laravel)
----------------------------------

[](#standalone-usage-without-laravel)

```
use PartnerApi\Logger\Logger;

$logger = new Logger(
    tenantToken: 'tenant_live_xxxxxxxxxxxx',
    baseUrl: 'https://ingest.partnerapi.com', // optional, this is the default
);
```

Logging
-------

[](#logging)

```
$logger->info($apiKey, 'Something happened', ['key' => 'value']);
$logger->warn($apiKey, 'Watch out');
$logger->error($apiKey, 'Something broke', ['error' => $e->getMessage()]);
$logger->debug($apiKey, 'Debug details');
```

### Context

[](#context)

Context fields persist across log calls and are included automatically:

```
$logger->setContext([
    'partnerId' => 'partner-123',
    'requestId' => $request->header('x-request-id'),
]);

// Both logs include partnerId and requestId
$logger->info($apiKey, 'Step 1');
$logger->info($apiKey, 'Step 2');
```

### HTTP Request / Response Logging

[](#http-request--response-logging)

```
$logger->logRequest($apiKey, [
    'method' => $request->method(),
    'path' => $request->path(),
    'headers' => $request->headers->all(),
    'body' => $request->all(),
]);

$logger->logResponse($apiKey, [
    'statusCode' => 200,
    'headers' => ['content-type' => 'application/json'],
    'body' => $responseData,
    'duration' => $durationMs,
    'correlationId' => $correlationId,
]);
```

Sensitive headers (`Authorization`, `Cookie`, `X-API-Key`, etc.) are automatically redacted.

Metrics
-------

[](#metrics)

Send business metrics to track over time:

```
// Single data point
$logger->metric($apiKey, [
    'slug' => 'revenue',
    'timestamp' => '2024-06-01T00:00:00Z',
    'value' => 54000,
    'period' => 'Jun 01',
    'metadata' => ['currency' => 'EUR'], // optional
]);

// Batch
$logger->metrics($apiKey, 'revenue', [
    ['timestamp' => '2024-06-01T00:00:00Z', 'value' => 54000, 'period' => 'Jun 01'],
    ['timestamp' => '2024-06-08T00:00:00Z', 'value' => 55200, 'period' => 'Jun 08'],
    ['timestamp' => '2024-06-15T00:00:00Z', 'value' => 58100, 'period' => 'Jun 15'],
]);
```

Error Handling
--------------

[](#error-handling)

All methods throw `PartnerApi\Logger\LoggerException` on failure:

```
use PartnerApi\Logger\LoggerException;

try {
    $logger->info($apiKey, 'Hello');
} catch (LoggerException $e) {
    // Handle failure
}
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance88

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

60d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f0eabb00c3b8b84ed2177cfeaf38c82924008a916fcf43f41a3f1d2964105e7d?d=identicon)[okjake](/maintainers/okjake)

---

Top Contributors

[![okjake](https://avatars.githubusercontent.com/u/316538?v=4)](https://github.com/okjake "okjake (2 commits)")

---

Tags

laravelloggingsdkMetricsPartner-API

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/partner-api-logger/health.svg)

```
[![Health](https://phpackages.com/badges/partner-api-logger/health.svg)](https://phpackages.com/packages/partner-api-logger)
```

###  Alternatives

[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2222.9M248](/packages/open-telemetry-sdk)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[hosmelq/laravel-logsnag

Integrate the power of LogSnag's real-time event tracking into your Laravel application.

237.9k](/packages/hosmelq-laravel-logsnag)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
