HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
Logger.php
Go to the documentation of this file.
1 <?php
2 # @var $message - string
3 class Logger
4 {
5  public static function log($message, $isJson = false)
6  {
7  $from = array(
8  ',',
9  '{',
10  '}',
11  ':{'
12  );
13  $to = array(
14  ",\n ",
15  "{\n ",
16  "\n}",
17  ":\n{\t"
18  );
19  if ($isJson) {
20  $message = str_replace($from, $to, $message);
21  }
22  $logPath = (Yii::app()->getBasePath() . '/runtime');
23  $log = fopen($logPath . '/last.log', 'a');
24  $logHistory = fopen($logPath . '/'.date('Y-m-d').'_dc-ui.log', 'a');
25  $string = date("\n\n" . '[d-m-Y H:i:s] >>> ') . $message;
26  fwrite($log, CHtml::encode($string));
27  fclose($log);
28  fwrite($logHistory, $string);
29  fclose($logHistory);
30  }
31  public static function getTrace()
32  {
33  $logPath = (Yii::app()->getBasePath() . '/runtime');
34  $logContent = file_get_contents($logPath . '/last.log');
35  return $logContent;
36  }
37  public static function cleanLog()
38  {
39  $logPath = (Yii::app()->getBasePath() . '/runtime');
40  $log = fopen($logPath . '/last.log', 'w');
41  }
42 }
43 ?>