Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Zunke committed Feb 12, 2016
2 parents aa56320 + 25bd348 commit 7f60759
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
SlackBundle v1.4.0
==================
- Feature: Monolog-Logger uses colored attachments based on the log level (by @jdecoster)
- Patch: Quoting Services to Support Symfony > 2.8 (by @carlosmasip)
- Patch: Fix deprecation in configuration
- Patch: Enable Symfony 3.0 and PHP 7

SlackBundle v1.3.0
==================
- Feature: File upload service now accepts an array of channels, string usage is deprecated
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getConfigTreeBuilder()
->end()
->integerNode('limit_retries')
->defaultValue(3)
->cannotBeEmpty()
->min(1)
->info('The amount of retries for the connection if the Rate Limits of Slack are reached')
->end()
->end();
Expand Down
24 changes: 23 additions & 1 deletion Monolog/Handler/SlackHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DZunke\SlackBundle\Monolog\Handler;

use DZunke\SlackBundle\Slack\Entity\MessageAttachment;
use DZunke\SlackBundle\Slack\Messaging;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\AbstractProcessingHandler;
Expand Down Expand Up @@ -47,7 +48,28 @@ public function __construct(Messaging $messaging, $channel, $username, $level =

protected function write(array $record)
{
$this->messagingClient->message($this->channel, $record["formatted"], $this->username);
$attachment = new MessageAttachment();

switch($record['level']) {
case Logger::DEBUG:
case Logger::INFO:
$attachment->setColor('good');
break;
case Logger::NOTICE:
case Logger::WARNING:
$attachment->setColor('warning');
break;
case Logger::ERROR:
case Logger::CRITICAL:
case Logger::ALERT:
case Logger::EMERGENCY:
$attachment->setColor('danger');
break;
}

$attachment->addField($record['level_name'], $record['formatted']);

$this->messagingClient->message($this->channel, '', $this->username, [$attachment]);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ services:

dz.slack.client:
class: DZunke\SlackBundle\Slack\Client
arguments: [@dz.slack.connection]
arguments: ["@dz.slack.connection"]

dz.slack.messaging:
class: DZunke\SlackBundle\Slack\Messaging
arguments: [@dz.slack.client, @dz.slack.identity_bag]
arguments: ["@dz.slack.client", "@dz.slack.identity_bag"]

dz.slack.channels:
class: DZunke\SlackBundle\Slack\Channels
arguments: [@dz.slack.client]
arguments: ["@dz.slack.client"]

dz.slack.users:
class: DZunke\SlackBundle\Slack\Users
arguments: [@dz.slack.client]
arguments: ["@dz.slack.client"]
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"exclude": ["/Tests"]
},
"require": {
"php": ">=5.4.0",
"php": ">=5.4",
"symfony/symfony": "~2.3|~3.0",
"guzzle/guzzle": ">=3.7.0"
},
"autoload": {
Expand Down

0 comments on commit 7f60759

Please sign in to comment.