Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Added support for Datahub to LeLogger.php
Browse files Browse the repository at this point in the history
  • Loading branch information
seibertm authored and seibertm committed Aug 29, 2014
1 parent 13a0cf4 commit 6de3cac
Showing 1 changed file with 46 additions and 8 deletions.
54 changes: 46 additions & 8 deletions LeLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class LeLogger
private $resource = null;

private $_logToken = null;

// new variable for datahub ip address
private $_datahubIPAddress = null;
private $use_datahub = false;

private $severity = LOG_DEBUG;

Expand All @@ -60,11 +64,11 @@ class LeLogger

private $errstr;

public static function getLogger($token, $persistent, $ssl, $severity)
public static function getLogger($token, $datahubIPAddress, $persistent, $ssl, $severity, $datahubEnabled)
{
if (!self::$m_instance)
{
self::$m_instance = new LeLogger($token, $persistent, $ssl, $severity);
self::$m_instance = new LeLogger($token, $datahubIPAddress, $persistent, $ssl, $severity, $datahubEnabled);
}

return self::$m_instance;
Expand All @@ -76,10 +80,22 @@ public static function tearDown()
self::$m_instance = NULL;
}

private function __construct($token, $persistent, $use_ssl, $severity)
private function __construct($token, $datahubIPAddress, $persistent, $use_ssl, $severity, $datahubEnabled)
{
$this->validateToken($token);


// only validate the token when user is not using Datahub
if ($datahubEnabled === false)
{
$this->validateToken($token);
}
// only set datahub IP Address if using datahub.
else
{
// validate ip address????
$this->_datahubIPAddress = $datahubIPAddress;
$this->use_datahub = $datahubEnabled;
}

$this->_logToken = $token;

$this->persistent = $persistent;
Expand All @@ -97,7 +113,8 @@ public function __destruct()
}

public function validateToken($token){
if (empty($token)){

if (empty($token) {
throw new InvalidArgumentException('Logentries Token was not provided in logentries.php');
}
}
Expand All @@ -120,6 +137,8 @@ public function isTLS()
return $this->use_ssl;
}



public function getPort()
{
if ($this->isTLS())
Expand All @@ -129,13 +148,25 @@ public function getPort()
return self::LE_PORT;
}
}

// check if datahub is enabled
public function isDatahub()
{
return $this->_datahubEnabled;
}

// **** MAY NEED TO CHECK OTHER CONDITIONS HERE *****
public function getAddress()
{
if ($this->isTLS())
if ($this->isTLS() && this->isDatahub()===false )
{
return self::LE_TLS_ADDRESS;
}else{
}
else if ($this->isDatahub()
{
return self::_datahubIPAddress;
}
else{
return self::LE_ADDRESS;
}
}
Expand All @@ -148,7 +179,14 @@ public function isConnected()
private function createSocket()
{
$port = $this->getPort();
// delete before production
echo "port = " . $port . "\n";

// delete before production
$address = $this->getAddress();
echo "address = " . $address . "\n";


if ($this->isPersistent())
{
$resource = $this->my_pfsockopen($port, $address);
Expand Down

1 comment on commit 6de3cac

@L1lle
Copy link

@L1lle L1lle commented on 6de3cac Sep 11, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Update and that whole Datahub-Think should have been somehow communicated. A composer update later and nothing is working anymore because PHP is missing the arguments.

Please sign in to comment.