Skip to content

Commit

Permalink
0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
KanDisheng committed Feb 7, 2018
1 parent 8d6e484 commit f1922b3
Show file tree
Hide file tree
Showing 17 changed files with 705 additions and 140 deletions.
2 changes: 2 additions & 0 deletions .coveralls.yml
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
2 changes: 2 additions & 0 deletions .develop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ indent_size=4
insert_final_newline=false
trim_trailing_whitespace=false

[*.{php}]
[*.php]
insert_final_newline=true
trim_trailing_whitespace=true
9 changes: 6 additions & 3 deletions .gitignore
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
30 changes: 24 additions & 6 deletions .travis.yml
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"
18 changes: 11 additions & 7 deletions README.md
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)
18 changes: 18 additions & 0 deletions autoload.php
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);
178 changes: 178 additions & 0 deletions class/Log.php
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);
}
}
34 changes: 28 additions & 6 deletions composer.json
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"
}
}
Loading

0 comments on commit f1922b3

Please sign in to comment.