Skip to content

Commit

Permalink
Rebranded to Kdyby
Browse files Browse the repository at this point in the history
  • Loading branch information
fprochazka committed Jun 1, 2014
1 parent 3078fbb commit ade0b2f
Show file tree
Hide file tree
Showing 19 changed files with 461 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
docs export-ignore
tests export-ignore
3 changes: 2 additions & 1 deletion .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nbproject
vendor
composer.lock
27 changes: 27 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
language: php

env:
- NETTE=default # 2.2 dev
- NETTE=nette-2.1

php:
- 5.3.3
- 5.4
- 5.5
- 5.6
- hhvm

matrix:
allow_failures:
- php: hhvm

before_script:
- "php tests/prepare-composer.php"
- composer self-update
- composer install --no-interaction --prefer-source --dev
- ./vendor/bin/parallel-lint -e php,phpt --exclude vendor .

script: ./vendor/bin/tester -c ./tests/php.ini-unix ./tests/KdybyTests/

after_failure:
- 'for i in $(find ./tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done'
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Kdyby/Monolog
======

[![Build Status](https://travis-ci.org/Kdyby/Monolog.svg?branch=master)](https://travis-ci.org/Kdyby/Monolog)
[![Downloads this Month](https://img.shields.io/packagist/dm/kdyby/monolog.svg)](https://packagist.org/packages/kdyby/monolog)
[![Latest stable](https://img.shields.io/packagist/v/kdyby/monolog.svg)](https://packagist.org/packages/kdyby/monolog)

Integration of [Monolog](https://github.com/Seldaek/monolog) into Nette Framework


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

Kdyby/Monolog requires PHP 5.3.2 or higher.

- [Nette Framework](https://github.com/nette/nette)
- [Monolog](https://github.com/Seldaek/monolog)


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

The best way to install Kdyby/Monolog is using [Composer](http://getcomposer.org/):

```sh
$ composer require kdyby/monolog:@dev
```


Documentation
------------

Lear more in [documentation](https://github.com/Kdyby/Monolog/blob/master/docs/en/index.md).



-----

Homepage [http://www.kdyby.org](http://www.kdyby.org) and repository [http://github.com/Kdyby/Monolog](http://github.com/Kdyby/Monolog).
61 changes: 41 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
{
"name": "bazo/nette-monolog-extension",
"type": "nette-addon",
"description": "Nette monolog compiler extension",
"keywords": ["nette", "monolog", "logging", "extension"],
"homepage": "https://github.com/bazo/nette-monolog-extension",
"authors": [
{
"name": "Martin Bažík",
"email": "[email protected]",
"homepage": "http://bazo.sk"
}
],
"require": {
"php": ">= 5.4.0",
"monolog/monolog": "@dev"
},
"autoload": {
"psr-0": { "Bazo\\Monolog\\": "src/" }
}
}
"name": "kdyby/monolog",
"type": "library",
"description": "Integration of Monolog into Nette Framework",
"keywords": ["nette", "monolog", "logging", "diagnostics"],
"homepage": "http://kdyby.org",
"license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"authors": [
{
"name": "Martin Bažík",
"email": "[email protected]",
"homepage": "http://bazo.sk"
},
{
"name": "Filip Procházka",
"homepage": "http://filip-prochazka.com",
"email": "[email protected]"
}
],
"require": {
"nette/nette": "~2.1@dev",
"monolog/monolog": "~1.9"
},
"require-dev": {
"nette/tester": "@dev",
"jakub-onderka/php-parallel-lint": "~0.6"
},
"support": {
"email": "[email protected]",
"issues": "https://github.com/kdyby/monolog/issues"
},
"autoload": {
"psr-0": {
"Kdyby\\Monolog\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
}
}
}
57 changes: 57 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Licenses
========

Good news! You may use Kdyby Framework under the terms of either
the New BSD License or the GNU General Public License (GPL) version 2 or 3.

The BSD License is recommended for most projects. It is easy to understand and it
places almost no restrictions on what you can do with the framework. If the GPL
fits better to your project, you can use the framework under this license.

You don't have to notify anyone which license you are using. You can freely
use Kdyby Framework in commercial projects as long as the copyright header
remains intact.



New BSD License
---------------

Copyright (c) 2008 Filip Procházka (http://filip-prochazka.com)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of "Kdyby Framework" nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

This software is provided by the copyright holders and contributors "as is" and
any express or implied warranties, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose are
disclaimed. In no event shall the copyright owner or contributors be liable for
any direct, indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or services;
loss of use, data, or profits; or business interruption) however caused and on
any theory of liability, whether in contract, strict liability, or tort
(including negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.



GNU General Public License
--------------------------

GPL licenses are very very long, so instead of including them here we offer
you URLs with full text:

- [GPL version 2](http://www.gnu.org/licenses/gpl-2.0.html)
- [GPL version 3](http://www.gnu.org/licenses/gpl-3.0.html)
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
<?php

namespace Bazo\Monolog\DI;
/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.md that was distributed with this source code.
*/

namespace Kdyby\Monolog\DI;

use Nette;
use Nette\Configurator;
use Nette\DI\Compiler;
use Nette\DI\CompilerExtension;
use Nette\DI\Statement;
use Nette\PhpGenerator\PhpLiteral;
use Nette\PhpGenerator as Code;



if (!class_exists('Nette\DI\CompilerExtension')) {
class_alias('Nette\Config\CompilerExtension', 'Nette\DI\CompilerExtension');
class_alias('Nette\Config\Compiler', 'Nette\DI\Compiler');
class_alias('Nette\Config\Helpers', 'Nette\DI\Config\Helpers');
}

if (isset(Nette\Loaders\NetteLoader::getInstance()->renamed['Nette\Configurator']) || !class_exists('Nette\Configurator')) {
unset(Nette\Loaders\NetteLoader::getInstance()->renamed['Nette\Configurator']); // fuck you
class_alias('Nette\Config\Configurator', 'Nette\Configurator');
}

/**
* Monolog extension
*
* @author Martin Bažík <[email protected]>
* @author Filip Procházka <[email protected]>
*/
class MonologExtension extends \Nette\DI\CompilerExtension
class MonologExtension extends CompilerExtension
{

const TAG_HANDLER = 'monolog.handler';
Expand Down Expand Up @@ -53,7 +75,7 @@ public function loadConfiguration()
}

$builder->addDefinition($this->prefix('adapter'))
->setClass('Bazo\Monolog\Adapter\MonologAdapter', [$this->prefix('@logger')])
->setClass('Kdyby\Monolog\Diagnostics\MonologAdapter', [$this->prefix('@logger')])
->addTag('logger');
}

Expand Down Expand Up @@ -81,14 +103,14 @@ public function beforeCompile()
: 'Nette\Diagnostics\Debugger::$logger';

$logger->addSetup('pushHandler', array(
new Statement('Bazo\Monolog\Handler\FallbackNetteHandler', array(new PhpLiteral($code)))
new Statement('Kdyby\Monolog\Handler\FallbackNetteHandler', array(new Code\PhpLiteral($code)))
));
}
}



public function afterCompile(\Nette\PhpGenerator\ClassType $class)
public function afterCompile(Code\ClassType $class)
{
$config = $this->getConfig($this->defaults);

Expand All @@ -106,5 +128,14 @@ public function afterCompile(\Nette\PhpGenerator\ClassType $class)
}
}



public static function register(Configurator $configurator)
{
$configurator->onCompile[] = function ($config, Compiler $compiler) {
$compiler->addExtension('monolog', new MonologExtension());
};
}

}

Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
<?php

namespace Bazo\Monolog\Adapter;
/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008 Filip Procházka ([email protected])
*
* For the full copyright and license information, please view the file license.md that was distributed with this source code.
*/

namespace Kdyby\Monolog\Diagnostics;

use Bazo\Monolog\Handler\FallbackNetteHandler;
use Monolog\Logger;
use Nette\Diagnostics\Debugger;
use Kdyby\Monolog\Handler\FallbackNetteHandler;
use Monolog;
use Tracy\Debugger;
use Tracy\Logger;



if (!class_exists('Tracy\Debugger')) {
class_alias('Nette\Diagnostics\Debugger', 'Tracy\Debugger');
}

if (!class_exists('Tracy\Logger')) {
class_alias('Nette\Diagnostics\Logger', 'Tracy\Logger');
}

/**
* MonologAdapter
*
* @author Martin Bažík <[email protected]>
* @author Filip Procházka <[email protected]>
*/
class MonologAdapter extends \Nette\Diagnostics\Logger
class MonologAdapter extends Logger
{

/** @var Logger */
/**
* @var Monolog\Logger
*/
private $monolog;



public function __construct(Logger $monolog)
public function __construct(Monolog\Logger $monolog)
{
$this->monolog = $monolog;
}
Expand All @@ -40,7 +58,7 @@ public function log($message, $priority = self::INFO)
}

$levels = $this->monolog->getLevels();
$level = isset($levels[$uPriority = strtoupper($priority)]) ? $levels[$uPriority] : Logger::INFO;
$level = isset($levels[$uPriority = strtoupper($priority)]) ? $levels[$uPriority] : Monolog\Logger::INFO;

switch ($priority) {
case 'access':
Expand All @@ -53,11 +71,11 @@ public function log($message, $priority = self::INFO)



public static function register(Logger $monolog)
public static function register(Monolog\Logger $monolog)
{
$adapter = new static($monolog);

if (method_exists('Nette\Diagnostics\Debugger', 'setLogger')) {
if (method_exists('Tracy\Debugger', 'setLogger')) {
$monolog->pushHandler(new FallbackNetteHandler(Debugger::getLogger()));
Debugger::setLogger($adapter);

Expand Down
Loading

0 comments on commit ade0b2f

Please sign in to comment.