Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- date_default_timezone_set('Europe/Budapest');
- class Log {
- const Logdir = "Logs";
- static $timeStamp = "y-m-d H:i:s";
- static $fileName = "ks-sync.txt";
- public function __construct(){
- $this->CreateDirectory();
- $this->CreateFile();
- }
- public static function Add($string){
- if(!empty($string)){
- $string = self::logTime().$string.PHP_EOL;
- $filename = RPC_LOGS_LIB.'/'.Log::LogFileName();
- file_put_contents($filename,$string,FILE_APPEND);
- }
- }
- public static function logTime(){
- return date('Y-m-d H:i:s: ');
- }
- public static function logDate(){
- return date('Y-m-d');
- }
- static function LogFileName(){
- return Log::LogDate().'-'.self::$fileName;
- }
- // Create today's logfile if not exist
- public function CreateFile(){
- if(!file_exists(RPC_LOGS_LIB.'/'.Log::LogFileName())){
- file_put_contents(RPC_LOGS_LIB.'/'.Log::LogFileName(),self::logTime().'Log file created.');
- }
- }
- // Create Logs directory if not exist
- public function CreateDirectory(){
- if(!file_exists(RPC_LOGS_LIB)){
- mkdir('../'.self::Logdir,0777);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement