Skip to content

Commit

Permalink
implement Logger add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
wujunze committed Apr 23, 2018
1 parent 73ad7fb commit a379bc5
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 23 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "seasx/seaslogger",
"name": "seasx/seas-logger",
"description": "An effective,fast,stable log package for PHP",
"keywords": [
"log",
Expand All @@ -17,19 +17,19 @@
"require": {
"php": "^7.0",
"psr/log": "^1.0.2",
"ext-SeasLog": "^1.8"
"ext-SeasLog": "^1.7"
},
"require-dev": {
"phpunit/phpunit": "^6.5"
},
"autoload": {
"psr-4": {
"SeasX\\Seaslogger\\": "src"
"Seasx\\SeasLogger\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"SeasX\\Seaslogger\\Tests\\": "tests"
"Seasx\\SeasLogger\\Tests\\": "tests/"
}
},
"scripts": {
Expand Down
30 changes: 11 additions & 19 deletions src/Logger.php
Original file line number Diff line number Diff line change
@@ -1,101 +1,93 @@
<?php

namespace SeasX\SeasLogger;
namespace Seasx\SeasLogger;


use Psr\Log\LoggerInterface;
use \SeasLog;

class Logger implements LoggerInterface
{
/**
* @param string $message
* @param array $context
* @return mixed
*/
public function emergency($message, array $context = array())
{
// TODO: Implement emergency() method.
SeasLog::emergency($message, $context);
}

/**
* @param string $message
* @param array $context
* @return mixed
*/
public function alert($message, array $context = array())
{
// TODO: Implement alert() method.
SeasLog::alert($message, $context);
}

/**
* @param string $message
* @param array $context
* @return mixed
*/
public function critical($message, array $context = array())
{
// TODO: Implement critical() method.
SeasLog::critical($message, $context);
}

/**
* @param string $message
* @param array $context
* @return mixed
*/
public function error($message, array $context = array())
{
// TODO: Implement error() method.
SeasLog::error($message, $context);
}

/**
* @param string $message
* @param array $context
* @return mixed
*/
public function warning($message, array $context = array())
{
// TODO: Implement warning() method.
SeasLog::warning($message, $context);
}

/**
* @param string $message
* @param array $context
* @return mixed
*/
public function notice($message, array $context = array())
{
// TODO: Implement notice() method.
SeasLog::notice($message, $context);
}

/**
* @param string $message
* @param array $context
* @return mixed
*/
public function info($message, array $context = array())
{
// TODO: Implement info() method.
SeasLog::info($message, $context);
}

/**
* @param string $message
* @param array $context
* @return mixed
*/
public function debug($message, array $context = array())
{
// TODO: Implement debug() method.
SeasLog::debug($message, $context);
}

/**
* @param mixed $level
* @param string $message
* @param array $context
* @return mixed
*/
public function log($level, $message, array $context = array())
{
// TODO: Implement log() method.
SeasLog::log($level, $message, $context);
}


Expand Down
69 changes: 69 additions & 0 deletions tests/LoggerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Seasx\SeasLogger\Tests;

use Seasx\SeasLogger\Logger;

class LoggerTest extends TestCase
{
/**
* @return Logger
*/
public function init () {
return new Logger();
}

public function testEmergency() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->emergency('[SeasLog Test]', ['level' => 'emergency']);
}

public function testAlert() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->alert('[SeasLog Test]', ['level' => 'alert']);
}

public function testCritical() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->critical('[SeasLog Test]', ['level' => 'critical']);
}

public function testError() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->critical('[SeasLog Test]', ['level' => 'error']);
}

public function testWarning() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->warning('[SeasLog Test]', ['level' => 'warning']);
}

public function testNotice() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->notice('[SeasLog Test]', ['level' => 'notice']);
}

public function testInfo() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->info('[SeasLog Test]', ['level' => 'info']);
}

public function testDebug() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->debug('[SeasLog Test]', ['level' => 'debug']);
}

public function testLog() {
$logger = $this->init();
$this->assertInstanceOf(Logger::class, $logger);
$logger->log('debug','[SeasLog Test]', ['level' => 'log']);
}
}

0 comments on commit a379bc5

Please sign in to comment.