-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
8d6e484
commit f1922b3
Showing
17 changed files
with
705 additions
and
140 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage_clover: workbench/code_coverage_report/clover/clover.xml | ||
json_path: workbench/code_coverage_report/clover/coveralls.json |
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,2 @@ | ||
{ | ||
} |
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,6 +1,9 @@ | ||
#IDE | ||
# IDE | ||
/.idea/ | ||
|
||
#Composer | ||
# Composer | ||
/vendor/ | ||
/composer.lock | ||
/composer.lock | ||
|
||
# Workbench | ||
/workbench |
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,15 +1,33 @@ | ||
language: php | ||
matrix: | ||
include: | ||
- php: 5.3 | ||
dist: precise | ||
dist: trusty | ||
sudo: required | ||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
before_script: | ||
- 7.2 | ||
- nightly | ||
- hhvm | ||
matrix: | ||
include: | ||
- php: 5.3 | ||
dist: precise | ||
allow_failures: | ||
- php: nightly | ||
- php: hhvm | ||
before_install: | ||
- echo "Start" | ||
install: | ||
- composer install | ||
before_script: | ||
- if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then sudo cat vendor/codemommy/developphp/file/hhvm.php.ini >> /etc/hhvm/php.ini; fi | ||
script: | ||
- vendor/bin/phpunit -v | ||
- vendor/bin/phpunit --verbose | ||
after_success: | ||
- travis_retry vendor/bin/php-coveralls --verbose | ||
after_failure: | ||
- echo "Error" | ||
after_script: | ||
- echo "Success" |
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,24 +1,28 @@ | ||
# CodeMommy LogPHP | ||
|
||
[![Minimum PHP Version](https://img.shields.io/badge/php->=5.3-8892BF.svg)](https://php.net) | ||
[![License](https://poser.pugx.org/CodeMommy/LogPHP/license)](LICENSE) | ||
[![Download](https://poser.pugx.org/CodeMommy/LogPHP/downloads)](https://packagist.org/packages/CodeMommy/LogPHP) | ||
[![Stable](https://poser.pugx.org/CodeMommy/LogPHP/version)](https://packagist.org/packages/CodeMommy/LogPHP) | ||
[![Unstable](https://poser.pugx.org/CodeMommy/LogPHP/v/unstable)](https://packagist.org/packages/CodeMommy/LogPHP) | ||
[![composer.lock Available](https://poser.pugx.org/CodeMommy/LogPHP/composerlock)](https://packagist.org/packages/CodeMommy/LogPHP) | ||
[![Build Status](https://travis-ci.org/CodeMommy/LogPHP.svg?branch=master)](https://travis-ci.org/CodeMommy/LogPHP) | ||
|
||
[![Coverage Status](https://coveralls.io/repos/github/CodeMommy/LogPHP/badge.svg?branch=master)](https://coveralls.io/github/CodeMommy/LogPHP?branch=master) | ||
|
||
> Log | ||
Visit [CodeMommy Website](http://www.codemommy.com) or [Packagist](https://packagist.org/packages/CodeMommy/LogPHP) to get more information. | ||
## Manual | ||
|
||
- [Version 1.0 简体中文](manual/1.0_SimplifiedChinese.md) | ||
|
||
## Authors | ||
## Contributor | ||
|
||
| Name | Identity | Social | | ||
| :--- | :------- | :----- | | ||
| Candison November | Creator | [Website](http://www.kandisheng.com) - [GitHub](https://github.com/KanDisheng) | | ||
- [Candison November](http://www.kandisheng.com) - Founder | ||
|
||
## More | ||
## Information | ||
|
||
- [Homepage](http://www.CodeMommy.com) | ||
- [GitHub](https://github.com/CodeMommy/LogPHP) | ||
- [Packagist](https://packagist.org/packages/CodeMommy/LogPHP) | ||
- [Feedback](https://github.com/CodeMommy/LogPHP/issues) | ||
- [About CodeMommy](https://github.com/CodeMommy/CodeMommy) |
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,18 @@ | ||
<?php | ||
|
||
/** | ||
* CodeMommy LogPHP | ||
* @author Candison November <www.kandisheng.com> | ||
*/ | ||
|
||
require_once('library/Autoload.php'); | ||
|
||
use CodeMommy\LogPHP\Library\Autoload; | ||
|
||
$autoloaDirectory = array( | ||
'library' => 'CodeMommy\\LogPHP\\Library', | ||
'interface' => 'CodeMommy\\LogPHP', | ||
'class' => 'CodeMommy\\LogPHP' | ||
); | ||
|
||
Autoload::directory($autoloaDirectory); |
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,178 @@ | ||
<?php | ||
|
||
/** | ||
* CodeMommy LogPHP | ||
* @author Candison November <www.kandisheng.com> | ||
*/ | ||
|
||
namespace CodeMommy\LogPHP; | ||
|
||
/** | ||
* Class Log | ||
* @package CodeMommy\LogPHP | ||
*/ | ||
class Log implements LogInterface | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private static $config = array(); | ||
|
||
/** | ||
* Write | ||
* @param string $name | ||
* @param string $type | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
private static function write($name = '', $type = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
$filePath = isset(self::$config[$name]) ? self::$config[$name] : ''; | ||
if (empty($filePath)) { | ||
return false; | ||
} | ||
$directory = dirname($filePath); | ||
if (!file_exists($directory)) { | ||
mkdir($directory, 0777, true); | ||
} | ||
$string = sprintf( | ||
'[%s] %s.%s: %s %s %s%s', | ||
date('Y-m-d H:i:s'), | ||
$name, | ||
$type, | ||
$message, | ||
json_encode($data), | ||
json_encode($other), | ||
PHP_EOL | ||
); | ||
file_put_contents($filePath, $string, FILE_APPEND); | ||
return true; | ||
} | ||
|
||
/** | ||
* Log constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Add Config | ||
* @param string $name | ||
* @param string $filePath | ||
*/ | ||
public static function addConfig($name = '', $filePath = 'log.log') | ||
{ | ||
self::$config[$name] = $filePath; | ||
} | ||
|
||
/** | ||
* Get Config | ||
* @return array | ||
*/ | ||
public static function getConfig() | ||
{ | ||
return self::$config; | ||
} | ||
|
||
/** | ||
* Clear Config | ||
*/ | ||
public static function clearConfig() | ||
{ | ||
self::$config = array(); | ||
} | ||
|
||
/** | ||
* Debug | ||
* @param string $name | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
public static function debug($name = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
return self::write($name, 'DEBUG', $message, $data, $other); | ||
} | ||
|
||
/** | ||
* Info | ||
* @param string $name | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
public static function info($name = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
return self::write($name, 'INFO', $message, $data, $other); | ||
} | ||
|
||
/** | ||
* Notice | ||
* @param string $name | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
public static function notice($name = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
return self::write($name, 'NOTICE', $message, $data, $other); | ||
} | ||
|
||
/** | ||
* Warning | ||
* @param string $name | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
public static function warning($name = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
return self::write($name, 'WARNING', $message, $data, $other); | ||
} | ||
|
||
/** | ||
* Error | ||
* @param string $name | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
public static function error($name = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
return self::write($name, 'ERROR', $message, $data, $other); | ||
} | ||
|
||
/** | ||
* Critical | ||
* @param string $name | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
public static function critical($name = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
return self::write($name, 'CRITICAL', $message, $data, $other); | ||
} | ||
|
||
/** | ||
* Alert | ||
* @param string $name | ||
* @param string $message | ||
* @param array $data | ||
* @param array $other | ||
* @return bool | ||
*/ | ||
public static function alert($name = '', $message = '', $data = array(), $other = array()) | ||
{ | ||
return self::write($name, 'ALERT', $message, $data, $other); | ||
} | ||
} |
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,36 +1,58 @@ | ||
{ | ||
"name": "codemommy/logphp", | ||
"version": "0.0.1", | ||
"type": "library", | ||
"license": "Apache-2.0", | ||
"homepage": "http://www.codemommy.com", | ||
"description": "Log", | ||
"keywords": [ | ||
"CodeMommy", | ||
"LogPHP", | ||
"Log", | ||
"PHP" | ||
], | ||
"license": "Apache 2.0", | ||
"homepage": "http://www.codemommy.com", | ||
"support": { | ||
"issues": "https://github.com/CodeMommy/LogPHP/issues", | ||
"source": "https://github.com/CodeMommy/LogPHP" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Candison November", | ||
"role": "Founder", | ||
"email": "kandisheng@163.com", | ||
"homepage": "http://www.kandisheng.com" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"CodeMommy\\LogPHP\\": "source/" | ||
"CodeMommy\\LogPHP\\Library\\": "library", | ||
"CodeMommy\\LogPHP\\": [ | ||
"interface", | ||
"class" | ||
] | ||
} | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "*" | ||
"autoload-dev": { | ||
"psr-4": { | ||
"CodeMommy\\Test\\": "test", | ||
"CodeMommy\\Script\\": "script" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=5.3.0", | ||
"monolog/monolog": "1.23.*" | ||
}, | ||
"require-dev": { | ||
"CodeMommy/DevelopPHP": "dev-master" | ||
}, | ||
"scripts": { | ||
"update-project": "CodeMommy\\DevelopPHP\\UpdateProject::start", | ||
"environment": "CodeMommy\\DevelopPHP\\Environment::start", | ||
"pdepend": "CodeMommy\\DevelopPHP\\PHPDepend::start", | ||
"phpunit": "CodeMommy\\DevelopPHP\\PHPUnit::start", | ||
"phpcbf": "CodeMommy\\DevelopPHP\\PHPCodeBeautifierAndFixer::start", | ||
"phpcs": "CodeMommy\\DevelopPHP\\PHPCodeSniffer::start", | ||
"phpmd": "CodeMommy\\DevelopPHP\\PHPMessDetector::start", | ||
"clean": "CodeMommy\\DevelopPHP\\Clean::all", | ||
"test": "CodeMommy\\DevelopPHP\\Test::start" | ||
} | ||
} |
Oops, something went wrong.