Skip to content

Commit

Permalink
Merge pull request #18 from nguyenanhung/develop
Browse files Browse the repository at this point in the history
update new version
  • Loading branch information
nguyenanhung authored Feb 17, 2019
2 parents 7b08eef + 45a3c35 commit 313ee5e
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 105 deletions.
37 changes: 0 additions & 37 deletions classmap.php

This file was deleted.

58 changes: 0 additions & 58 deletions composer.json.dist

This file was deleted.

21 changes: 16 additions & 5 deletions src/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public function setLoggerFilename($loggerFilename = '')
{
if (!empty($loggerFilename)) {
$this->loggerFilename = trim($loggerFilename);
} else {
$this->loggerFilename = 'Log-' . date('Y-m-d') . '.log';
}

return $this;
Expand Down Expand Up @@ -239,6 +241,8 @@ public function setLoggerDateFormat($loggerDateFormat = NULL)
{
if (!empty($loggerDateFormat) && is_string($loggerDateFormat)) {
$this->loggerDateFormat = $loggerDateFormat;
} else {
$this->loggerDateFormat = "Y-m-d H:i:s u";
}

return $this;
Expand Down Expand Up @@ -274,6 +278,8 @@ public function setLoggerLineFormat($loggerLineFormat = NULL)
{
if (!empty($loggerLineFormat) && is_string($loggerLineFormat)) {
$this->loggerLineFormat = $loggerLineFormat;
} else {
$this->loggerLineFormat = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
}

return $this;
Expand All @@ -300,6 +306,11 @@ public function log($level = '', $name = 'log', $msg = 'My Message', $context =
$level = strtolower(trim($level));
if ($this->DEBUG == TRUE) {
if (!class_exists('\Monolog\Logger')) {
if (function_exists('log_message')) {
$errorMsg = 'Không tồn tại class Monolog';
log_message('error', $errorMsg);
}

return FALSE;
}
try {
Expand All @@ -308,7 +319,7 @@ public function log($level = '', $name = 'log', $msg = 'My Message', $context =
if (empty($this->loggerFilename)) {
$this->loggerFilename = 'Log-' . date('Y-m-d') . '.log';
}
$listLevel = ['debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency'];
$listLevel = array('debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency');
if (
// Tồn tại Global Logger Level
isset($this->globalLoggerLevel) &&
Expand Down Expand Up @@ -351,8 +362,8 @@ public function log($level = '', $name = 'log', $msg = 'My Message', $context =
$keyLevel = \Monolog\Logger::WARNING;
}
$loggerFilename = $this->loggerPath . DIRECTORY_SEPARATOR . $loggerSubPath . DIRECTORY_SEPARATOR . $this->loggerFilename;
$dateFormat = $this->loggerDateFormat ? $this->loggerDateFormat : "Y-m-d H:i:s u";
$output = $this->loggerLineFormat ? $this->loggerLineFormat : "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
$dateFormat = !empty($this->loggerDateFormat) ? $this->loggerDateFormat : "Y-m-d H:i:s u";
$output = !empty($this->loggerLineFormat) ? $this->loggerLineFormat : "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n";
$formatter = new \Monolog\Formatter\LineFormatter($output, $dateFormat);
$stream = new \Monolog\Handler\StreamHandler($loggerFilename, $keyLevel, self::LOG_BUBBLE, self::FILE_PERMISSION);
$stream->setFormatter($formatter);
Expand All @@ -368,12 +379,12 @@ public function log($level = '', $name = 'log', $msg = 'My Message', $context =
}
}
catch (\Exception $e) {
$message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
if (function_exists('log_message')) {
$message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
log_message('error', $message);
}

return $message;
return FALSE;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ProjectInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
interface ProjectInterface
{
const VERSION = '0.1.3';
const VERSION = '0.1.4';

/**
* Hàm lấy thông tin phiên bản Packages
Expand Down
10 changes: 10 additions & 0 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public function __construct()
public static function slugify($str = '')
{
if (!class_exists('\Cocur\Slugify\Slugify')) {
if (function_exists('log_message')) {
$message = 'Không tồn tại class Slugify';
log_message('error', $message);
}

return self::convert_vi_to_en($str);
}
try {
Expand All @@ -55,6 +60,11 @@ public static function slugify($str = '')
return $slugify->slugify($str);
}
catch (\Exception $e) {
if (function_exists('log_message')) {
$message = 'Error Code: ' . $e->getCode() . ' - File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Message: ' . $e->getMessage();
log_message('error', $message);
}

return self::convert_vi_to_en($str);
}
}
Expand Down
1 change: 0 additions & 1 deletion test/test_benchmark.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; // Current Package test, remove if init other package
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'classmap.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'functions.php';

/**
Expand Down
1 change: 0 additions & 1 deletion test/test_debug.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; // Current Package test, remove if init other package
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'classmap.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'functions.php';

/**
Expand Down
1 change: 0 additions & 1 deletion test/test_file.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; // Current Package test, remove if init other package
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'classmap.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'functions.php';

/**
Expand Down
1 change: 0 additions & 1 deletion test/test_utils.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; // Current Package test, remove if init other package
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'classmap.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'functions.php';

/**
Expand Down

0 comments on commit 313ee5e

Please sign in to comment.