deprecated log class. removed from aliases. added storage/log.txt.
This commit is contained in:
parent
8053d8e954
commit
a6d1449b40
|
@ -30,14 +30,12 @@
|
|||
'Inflector' => 'System\\Inflector',
|
||||
'Input' => 'System\\Input',
|
||||
'Lang' => 'System\\Lang',
|
||||
'Log' => 'System\\Log',
|
||||
'URL' => 'System\\URL',
|
||||
'Redirect' => 'System\\Redirect',
|
||||
'Request' => 'System\\Request',
|
||||
'Response' => 'System\\Response',
|
||||
'Session' => 'System\\Session',
|
||||
'Str' => 'System\\Str',
|
||||
'Text' => 'System\\Text',
|
||||
'Validator' => 'System\\Validator',
|
||||
'View' => 'System\\View',
|
||||
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
<?php namespace System;
|
||||
|
||||
class Log {
|
||||
|
||||
/**
|
||||
* Write an info message to the log.
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public static function info($message)
|
||||
{
|
||||
static::write('Info', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a debug message to the log.
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public static function debug($message)
|
||||
{
|
||||
static::write('Debug', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an error message to the logs.
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public static function error($message)
|
||||
{
|
||||
static::write('Error', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a message to the logs.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public static function write($type, $message)
|
||||
{
|
||||
// Create the yearly and monthly directories if needed.
|
||||
static::make_directory($directory = APP_PATH.'storage/logs/'.date('Y'));
|
||||
static::make_directory($directory .= '/'.date('m'));
|
||||
|
||||
// Get the daily log file filename.
|
||||
$file = $directory.'/'.date('d').EXT;
|
||||
|
||||
file_put_contents($file, date('Y-m-d H:i:s').' '.$type.' - '.$message.PHP_EOL, LOCK_EX | FILE_APPEND);
|
||||
|
||||
chmod($file, 0666);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a log directory.
|
||||
*
|
||||
* If the directory already exists, no action will be taken.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return void
|
||||
*/
|
||||
private static function make_directory($directory)
|
||||
{
|
||||
if ( ! is_dir($directory))
|
||||
{
|
||||
mkdir($directory, 02777);
|
||||
chmod($directory, 02777);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue