This repository has been archived by the owner on Mar 17, 2020. It is now read-only.
-
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
Showing
6 changed files
with
68 additions
and
0 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 |
---|---|---|
|
@@ -11,6 +11,9 @@ Route.php | |
# Own Environment | ||
environment/* | ||
|
||
# Own Log | ||
log/* | ||
|
||
# Own Tests | ||
Test.php | ||
test.php |
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
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,11 +1,17 @@ | ||
<?php | ||
|
||
class Event { | ||
public function __construct() { | ||
|
||
} | ||
|
||
public static function addEventListener($event_name, $event_handler) { | ||
|
||
} | ||
|
||
public function __destruct() { | ||
echo View::getBuffer(); | ||
Log::finalize(); | ||
} | ||
} | ||
$event = new Event(); |
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,57 @@ | ||
<?php | ||
|
||
/** | ||
* Log | ||
* | ||
* ログを管理するクラスです | ||
* | ||
* @package ApplestFramework | ||
* @author miyukki<[email protected]> | ||
*/ | ||
class Log { | ||
private static $delay_mode = true; | ||
private static $output_mode = false; | ||
|
||
private static $logs = array(); | ||
|
||
public static function delay() { | ||
self::$delay_mode = false; | ||
} | ||
public static function output() { | ||
self::$output_mode = true; | ||
} | ||
|
||
public static function dump($object) { | ||
ob_start(); | ||
var_dump($object); | ||
$dump_str = ob_get_contents(); | ||
ob_end_clean(); | ||
self::write($dump_str); | ||
} | ||
|
||
public static function info($log_text) { | ||
self::write('INFO', $log_text); | ||
} | ||
|
||
public static function warn() { | ||
self::write('WARN', $log_text); | ||
} | ||
|
||
public static function error() { | ||
self::write('ERROR', $log_text); | ||
} | ||
|
||
private static function write($level, $log_text) { | ||
// self::$logs[] = '['.$level.'] '.date('Y:m:d H:i:s').' '.$log_text; | ||
self::$logs[] = sprintf('[%s] %s %s', $level, date('Y:m:d H:i:s'), $log_text); | ||
} | ||
|
||
public static function finalize() { | ||
$log_str = ''; | ||
foreach (self::$logs as $log) { | ||
$log_str .= $log.PHP_EOL; | ||
} | ||
$log_name = date('Ymd').'.log'; | ||
file_put_contents(Config::get('path.log').'/'.$log_name, $log_str, FILE_APPEND); | ||
} | ||
} |
Empty file.