This repository has been archived by the owner on Mar 2, 2019. It is now read-only.
forked from Seldaek/monolog
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
2,584 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
language: php | ||
|
||
php: | ||
- 5.2 | ||
- 5.3 | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- hhvm | ||
|
||
before_script: | ||
- "mkdir -p ~/.composer" | ||
- cp src/test/resources/travis-composer-config.json ~/.composer/config.json | ||
- wget https://raw.github.com/ehough/throwback/develop/src/main/bash/travis-setup.sh | ||
- if [ "`phpenv version-name`" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi | ||
- if [ "`phpenv version-name`" != "hhvm" ]; then echo "extension = amqp.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi | ||
- chmod a+x travis-setup.sh | ||
- ./travis-setup.sh | ||
script: "phpunit -c src/test/resources/phpunit.xml.dist" | ||
|
||
script: "phpunit -c src/test/resources/phpunit.xml.dist --coverage-clover=coverage.clover" | ||
|
||
after_script: | ||
- wget https://scrutinizer-ci.com/ocular.phar | ||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
{ | ||
"name": "ehough/epilog", | ||
"description": "Fork of seldaek/monolog compatible with PHP 5.2+.", | ||
"description": "Fork of seldaek/monolog compatible with PHP 5.2+", | ||
"homepage": "https://github.com/ehough/epilog", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Jordi Boggiano", | ||
"email": "[email protected]", | ||
"homepage": "http://seld.be" | ||
}, | ||
{ | ||
"name": "Eric Hough", | ||
"email": "eric@ehough.com", | ||
"email": "eric@tubepress.org", | ||
"homepage": "http://ehough.com" | ||
} | ||
], | ||
|
@@ -15,14 +20,29 @@ | |
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~3.7.0", | ||
"mlehner/gelf-php": "1.0.*", | ||
"raven/raven": "0.5.*", | ||
"graylog2/gelf-php": "~1.0", | ||
"raven/raven": "~0.5", | ||
"ruflin/elastica": "0.90.*", | ||
"doctrine/couchdb": "dev-master", | ||
"aws/aws-sdk-php": "~2.4.8", | ||
"doctrine/couchdb": "~1.0@dev", | ||
"aws/aws-sdk-php": "~2.4, >2.4.8", | ||
"ehough/pulsar": "~2.3" | ||
}, | ||
"autoload": { | ||
"psr-0": {"ehough_epilog": "src/main/php"} | ||
}, | ||
"suggest": { | ||
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", | ||
"raven/raven": "Allow sending log messages to a Sentry server", | ||
"doctrine/couchdb": "Allow sending log messages to a CouchDB server", | ||
"ruflin/elastica": "Allow sending log messages to an Elastic Search server", | ||
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", | ||
"ext-mongo": "Allow sending log messages to a MongoDB server", | ||
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", | ||
"rollbar/rollbar": "Allow sending log messages to Rollbar" | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.9.x-dev" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Monolog package. | ||
* | ||
* (c) Jordi Boggiano <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/** | ||
* Monolog log registry | ||
* | ||
* Allows to get `Logger` instances in the global scope | ||
* via static method calls on this class. | ||
* | ||
* <code> | ||
* $application = new Monolog\Logger('application'); | ||
* $api = new Monolog\Logger('api'); | ||
* | ||
* Monolog\Registry::addLogger($application); | ||
* Monolog\Registry::addLogger($api); | ||
* | ||
* function testLogger() | ||
* { | ||
* Monolog\Registry::api()->addError('Sent to $api Logger instance'); | ||
* Monolog\Registry::application()->addError('Sent to $application Logger instance'); | ||
* } | ||
* </code> | ||
* | ||
* @author Tomas Tatarko <[email protected]> | ||
*/ | ||
class ehough_epilog_Registry | ||
{ | ||
/** | ||
* List of all loggers in the registry (ba named indexes) | ||
* | ||
* @var ehough_epilog_Logger[] | ||
*/ | ||
private static $loggers = array(); | ||
|
||
/** | ||
* Adds new logging channel to the registry | ||
* | ||
* @param ehough_epilog_Logger $logger Instance of the logging channel | ||
* @param string|null $name Name of the logging channel ($logger->getName() by default) | ||
* @param boolean $overwrite Overwrite instance in the registry if the given name already exists? | ||
* @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists | ||
*/ | ||
public static function addLogger(ehough_epilog_Logger $logger, $name = null, $overwrite = false) | ||
{ | ||
$name = $name ? $name : $logger->getName(); | ||
|
||
if (isset(self::$loggers[$name]) && !$overwrite) { | ||
throw new InvalidArgumentException('Logger with the given name already exists'); | ||
} | ||
|
||
self::$loggers[$name] = $logger; | ||
} | ||
|
||
/** | ||
* Removes instance from registry by name or instance | ||
* | ||
* @param string|ehough_epilog_Logger $logger Name or logger instance | ||
*/ | ||
public static function removeLogger($logger) | ||
{ | ||
if ($logger instanceof ehough_epilog_Logger) { | ||
if (false !== ($idx = array_search($logger, self::$loggers, true))) { | ||
unset(self::$loggers[$idx]); | ||
} | ||
} else { | ||
unset(self::$loggers[$logger]); | ||
} | ||
} | ||
|
||
/** | ||
* Clears the registry | ||
*/ | ||
public static function clear() | ||
{ | ||
self::$loggers = array(); | ||
} | ||
|
||
/** | ||
* Gets Logger instance from the registry | ||
* | ||
* @param string $name Name of the requested Logger instance | ||
* @return ehough_epilog_Logger Requested instance of Logger | ||
* @throws \InvalidArgumentException If named Logger instance is not in the registry | ||
*/ | ||
public static function getInstance($name) | ||
{ | ||
if (!isset(self::$loggers[$name])) { | ||
throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name)); | ||
} | ||
|
||
return self::$loggers[$name]; | ||
} | ||
|
||
/** | ||
* Gets Logger instance from the registry via static method call | ||
* | ||
* @param string $name Name of the requested Logger instance | ||
* @param array $arguments Arguments passed to static method call | ||
* @return ehough_epilog_Logger Requested instance of Logger | ||
* @throws \InvalidArgumentException If named Logger instance is not in the registry | ||
*/ | ||
public static function __callStatic($name, $arguments) | ||
{ | ||
return self::getInstance($name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/main/php/ehough/epilog/formatter/FlowdockFormatter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
/** | ||
* formats the record to be used in the FlowdockHandler | ||
* | ||
* @author Dominik Liebler <[email protected]> | ||
*/ | ||
class ehough_epilog_formatter_FlowdockFormatter implements ehough_epilog_formatter_FormatterInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $source; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $sourceEmail; | ||
|
||
/** | ||
* @param string $source | ||
* @param string $sourceEmail | ||
*/ | ||
public function __construct($source, $sourceEmail) | ||
{ | ||
$this->source = $source; | ||
$this->sourceEmail = $sourceEmail; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function format(array $record) | ||
{ | ||
$tags = array( | ||
'#logs', | ||
'#' . strtolower($record['level_name']), | ||
'#' . $record['channel'], | ||
); | ||
|
||
foreach ($record['extra'] as $value) { | ||
$tags[] = '#' . $value; | ||
} | ||
|
||
$subject = sprintf( | ||
'in %s: %s - %s', | ||
$this->source, | ||
$record['level_name'], | ||
$this->getShortMessage($record['message']) | ||
); | ||
|
||
$record['flowdock'] = array( | ||
'source' => $this->source, | ||
'from_address' => $this->sourceEmail, | ||
'subject' => $subject, | ||
'content' => $record['message'], | ||
'tags' => $tags, | ||
'project' => $this->source, | ||
); | ||
|
||
return $record; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function formatBatch(array $records) | ||
{ | ||
$formatted = array(); | ||
|
||
foreach ($records as $record) { | ||
$formatted[] = $this->format($record); | ||
} | ||
|
||
return $formatted; | ||
} | ||
|
||
/** | ||
* @param string $message | ||
* | ||
* @return string | ||
*/ | ||
public function getShortMessage($message) | ||
{ | ||
$maxLength = 45; | ||
|
||
if (strlen($message) > $maxLength) { | ||
$message = substr($message, 0, $maxLength - 4) . ' ...'; | ||
} | ||
|
||
return $message; | ||
} | ||
} |
Oops, something went wrong.