Logging for PHP SDK

How to enable logging

Required UUID

Always set the UUID to uniquely identify the user or device that connects to PubNub. This UUID should be persisted, and should remain unchanged for the lifetime of the user or the device. If you don't set the UUID, you won't be able to connect to PubNub.

<?php

// Include Composer autoloader (adjust path if needed)
require_once 'vendor/autoload.php';

use Monolog\Level;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\ErrorLogHandler;
use Monolog\Formatter\LineFormatter;
use PubNub\PNConfiguration;
use PubNub\PubNub;
use PubNub\Exceptions\PubNubException;

/**
show all 101 lines

How to disable logging

You can disable the STDOUT print statements by ommiting configuration of logger. Default PSR/Log/NullLogger will be used.

Using this code sample you can discard all log message output:

<?php

// Include Composer autoloader (adjust path if needed)
require_once 'vendor/autoload.php';

use PubNub\PNConfiguration;
use PubNub\PubNub;
use PubNub\Exceptions\PubNubException;

/**
* Basic PubNub PHP SDK Initialization Example
*/
try {
// Create a new configuration
$pnconf = new PNConfiguration();
show all 45 lines
Last updated on