Skip to content

Commit f1922b3

Browse files
committed
0.0.2
1 parent 8d6e484 commit f1922b3

File tree

17 files changed

+705
-140
lines changed

17 files changed

+705
-140
lines changed

.coveralls.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage_clover: workbench/code_coverage_report/clover/clover.xml
2+
json_path: workbench/code_coverage_report/clover/coveralls.json

.develop.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ indent_size=4
88
insert_final_newline=false
99
trim_trailing_whitespace=false
1010

11-
[*.{php}]
11+
[*.php]
1212
insert_final_newline=true
1313
trim_trailing_whitespace=true

.gitignore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
#IDE
1+
# IDE
22
/.idea/
33

4-
#Composer
4+
# Composer
55
/vendor/
6-
/composer.lock
6+
/composer.lock
7+
8+
# Workbench
9+
/workbench

.travis.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,33 @@
11
language: php
2-
matrix:
3-
include:
4-
- php: 5.3
5-
dist: precise
2+
dist: trusty
3+
sudo: required
64
php:
75
- 5.4
86
- 5.5
97
- 5.6
108
- 7.0
119
- 7.1
12-
before_script:
10+
- 7.2
11+
- nightly
12+
- hhvm
13+
matrix:
14+
include:
15+
- php: 5.3
16+
dist: precise
17+
allow_failures:
18+
- php: nightly
19+
- php: hhvm
20+
before_install:
21+
- echo "Start"
22+
install:
1323
- composer install
24+
before_script:
25+
- if [[ $TRAVIS_PHP_VERSION =~ ^hhvm ]]; then sudo cat vendor/codemommy/developphp/file/hhvm.php.ini >> /etc/hhvm/php.ini; fi
1426
script:
15-
- vendor/bin/phpunit -v
27+
- vendor/bin/phpunit --verbose
28+
after_success:
29+
- travis_retry vendor/bin/php-coveralls --verbose
30+
after_failure:
31+
- echo "Error"
32+
after_script:
33+
- echo "Success"

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
# CodeMommy LogPHP
22

3+
[![Minimum PHP Version](https://img.shields.io/badge/php->=5.3-8892BF.svg)](https://php.net)
34
[![License](https://poser.pugx.org/CodeMommy/LogPHP/license)](LICENSE)
45
[![Download](https://poser.pugx.org/CodeMommy/LogPHP/downloads)](https://packagist.org/packages/CodeMommy/LogPHP)
56
[![Stable](https://poser.pugx.org/CodeMommy/LogPHP/version)](https://packagist.org/packages/CodeMommy/LogPHP)
67
[![Unstable](https://poser.pugx.org/CodeMommy/LogPHP/v/unstable)](https://packagist.org/packages/CodeMommy/LogPHP)
78
[![composer.lock Available](https://poser.pugx.org/CodeMommy/LogPHP/composerlock)](https://packagist.org/packages/CodeMommy/LogPHP)
89
[![Build Status](https://travis-ci.org/CodeMommy/LogPHP.svg?branch=master)](https://travis-ci.org/CodeMommy/LogPHP)
9-
10+
[![Coverage Status](https://coveralls.io/repos/github/CodeMommy/LogPHP/badge.svg?branch=master)](https://coveralls.io/github/CodeMommy/LogPHP?branch=master)
1011

1112
> Log
1213
13-
Visit [CodeMommy Website](http://www.codemommy.com) or [Packagist](https://packagist.org/packages/CodeMommy/LogPHP) to get more information.
14+
## Manual
15+
16+
- [Version 1.0 简体中文](manual/1.0_SimplifiedChinese.md)
1417

15-
## Authors
18+
## Contributor
1619

17-
| Name | Identity | Social |
18-
| :--- | :------- | :----- |
19-
| Candison November | Creator | [Website](http://www.kandisheng.com) - [GitHub](https://github.com/KanDisheng) |
20+
- [Candison November](http://www.kandisheng.com) - Founder
2021

21-
## More
22+
## Information
2223

24+
- [Homepage](http://www.CodeMommy.com)
25+
- [GitHub](https://github.com/CodeMommy/LogPHP)
26+
- [Packagist](https://packagist.org/packages/CodeMommy/LogPHP)
2327
- [Feedback](https://github.com/CodeMommy/LogPHP/issues)
2428
- [About CodeMommy](https://github.com/CodeMommy/CodeMommy)

autoload.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/**
4+
* CodeMommy LogPHP
5+
* @author Candison November <www.kandisheng.com>
6+
*/
7+
8+
require_once('library/Autoload.php');
9+
10+
use CodeMommy\LogPHP\Library\Autoload;
11+
12+
$autoloaDirectory = array(
13+
'library' => 'CodeMommy\\LogPHP\\Library',
14+
'interface' => 'CodeMommy\\LogPHP',
15+
'class' => 'CodeMommy\\LogPHP'
16+
);
17+
18+
Autoload::directory($autoloaDirectory);

class/Log.php

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
<?php
2+
3+
/**
4+
* CodeMommy LogPHP
5+
* @author Candison November <www.kandisheng.com>
6+
*/
7+
8+
namespace CodeMommy\LogPHP;
9+
10+
/**
11+
* Class Log
12+
* @package CodeMommy\LogPHP
13+
*/
14+
class Log implements LogInterface
15+
{
16+
/**
17+
* @var array
18+
*/
19+
private static $config = array();
20+
21+
/**
22+
* Write
23+
* @param string $name
24+
* @param string $type
25+
* @param string $message
26+
* @param array $data
27+
* @param array $other
28+
* @return bool
29+
*/
30+
private static function write($name = '', $type = '', $message = '', $data = array(), $other = array())
31+
{
32+
$filePath = isset(self::$config[$name]) ? self::$config[$name] : '';
33+
if (empty($filePath)) {
34+
return false;
35+
}
36+
$directory = dirname($filePath);
37+
if (!file_exists($directory)) {
38+
mkdir($directory, 0777, true);
39+
}
40+
$string = sprintf(
41+
'[%s] %s.%s: %s %s %s%s',
42+
date('Y-m-d H:i:s'),
43+
$name,
44+
$type,
45+
$message,
46+
json_encode($data),
47+
json_encode($other),
48+
PHP_EOL
49+
);
50+
file_put_contents($filePath, $string, FILE_APPEND);
51+
return true;
52+
}
53+
54+
/**
55+
* Log constructor.
56+
*/
57+
public function __construct()
58+
{
59+
}
60+
61+
/**
62+
* Add Config
63+
* @param string $name
64+
* @param string $filePath
65+
*/
66+
public static function addConfig($name = '', $filePath = 'log.log')
67+
{
68+
self::$config[$name] = $filePath;
69+
}
70+
71+
/**
72+
* Get Config
73+
* @return array
74+
*/
75+
public static function getConfig()
76+
{
77+
return self::$config;
78+
}
79+
80+
/**
81+
* Clear Config
82+
*/
83+
public static function clearConfig()
84+
{
85+
self::$config = array();
86+
}
87+
88+
/**
89+
* Debug
90+
* @param string $name
91+
* @param string $message
92+
* @param array $data
93+
* @param array $other
94+
* @return bool
95+
*/
96+
public static function debug($name = '', $message = '', $data = array(), $other = array())
97+
{
98+
return self::write($name, 'DEBUG', $message, $data, $other);
99+
}
100+
101+
/**
102+
* Info
103+
* @param string $name
104+
* @param string $message
105+
* @param array $data
106+
* @param array $other
107+
* @return bool
108+
*/
109+
public static function info($name = '', $message = '', $data = array(), $other = array())
110+
{
111+
return self::write($name, 'INFO', $message, $data, $other);
112+
}
113+
114+
/**
115+
* Notice
116+
* @param string $name
117+
* @param string $message
118+
* @param array $data
119+
* @param array $other
120+
* @return bool
121+
*/
122+
public static function notice($name = '', $message = '', $data = array(), $other = array())
123+
{
124+
return self::write($name, 'NOTICE', $message, $data, $other);
125+
}
126+
127+
/**
128+
* Warning
129+
* @param string $name
130+
* @param string $message
131+
* @param array $data
132+
* @param array $other
133+
* @return bool
134+
*/
135+
public static function warning($name = '', $message = '', $data = array(), $other = array())
136+
{
137+
return self::write($name, 'WARNING', $message, $data, $other);
138+
}
139+
140+
/**
141+
* Error
142+
* @param string $name
143+
* @param string $message
144+
* @param array $data
145+
* @param array $other
146+
* @return bool
147+
*/
148+
public static function error($name = '', $message = '', $data = array(), $other = array())
149+
{
150+
return self::write($name, 'ERROR', $message, $data, $other);
151+
}
152+
153+
/**
154+
* Critical
155+
* @param string $name
156+
* @param string $message
157+
* @param array $data
158+
* @param array $other
159+
* @return bool
160+
*/
161+
public static function critical($name = '', $message = '', $data = array(), $other = array())
162+
{
163+
return self::write($name, 'CRITICAL', $message, $data, $other);
164+
}
165+
166+
/**
167+
* Alert
168+
* @param string $name
169+
* @param string $message
170+
* @param array $data
171+
* @param array $other
172+
* @return bool
173+
*/
174+
public static function alert($name = '', $message = '', $data = array(), $other = array())
175+
{
176+
return self::write($name, 'ALERT', $message, $data, $other);
177+
}
178+
}

composer.json

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
11
{
22
"name": "codemommy/logphp",
3-
"version": "0.0.1",
3+
"type": "library",
4+
"license": "Apache-2.0",
5+
"homepage": "http://www.codemommy.com",
46
"description": "Log",
57
"keywords": [
68
"CodeMommy",
79
"LogPHP",
810
"Log",
911
"PHP"
1012
],
11-
"license": "Apache 2.0",
12-
"homepage": "http://www.codemommy.com",
1313
"support": {
1414
"issues": "https://github.com/CodeMommy/LogPHP/issues",
1515
"source": "https://github.com/CodeMommy/LogPHP"
1616
},
1717
"authors": [
1818
{
1919
"name": "Candison November",
20+
"role": "Founder",
2021
"email": "kandisheng@163.com",
2122
"homepage": "http://www.kandisheng.com"
2223
}
2324
],
2425
"autoload": {
2526
"psr-4": {
26-
"CodeMommy\\LogPHP\\": "source/"
27+
"CodeMommy\\LogPHP\\Library\\": "library",
28+
"CodeMommy\\LogPHP\\": [
29+
"interface",
30+
"class"
31+
]
2732
}
2833
},
29-
"require-dev": {
30-
"phpunit/phpunit": "*"
34+
"autoload-dev": {
35+
"psr-4": {
36+
"CodeMommy\\Test\\": "test",
37+
"CodeMommy\\Script\\": "script"
38+
}
3139
},
3240
"require": {
3341
"php": ">=5.3.0",
3442
"monolog/monolog": "1.23.*"
43+
},
44+
"require-dev": {
45+
"CodeMommy/DevelopPHP": "dev-master"
46+
},
47+
"scripts": {
48+
"update-project": "CodeMommy\\DevelopPHP\\UpdateProject::start",
49+
"environment": "CodeMommy\\DevelopPHP\\Environment::start",
50+
"pdepend": "CodeMommy\\DevelopPHP\\PHPDepend::start",
51+
"phpunit": "CodeMommy\\DevelopPHP\\PHPUnit::start",
52+
"phpcbf": "CodeMommy\\DevelopPHP\\PHPCodeBeautifierAndFixer::start",
53+
"phpcs": "CodeMommy\\DevelopPHP\\PHPCodeSniffer::start",
54+
"phpmd": "CodeMommy\\DevelopPHP\\PHPMessDetector::start",
55+
"clean": "CodeMommy\\DevelopPHP\\Clean::all",
56+
"test": "CodeMommy\\DevelopPHP\\Test::start"
3557
}
3658
}

0 commit comments

Comments
 (0)