浏览代码

Change Log.php to FileLog.php

Ishan Vyas 5 年之前
父节点
当前提交
73e72be638
共有 4 个文件被更改,包括 16 次插入16 次删除
  1. 1 1
      docs/README.md
  2. 6 6
      docs/Utility/Log.md
  3. 1 1
      src/Utility/Log.php
  4. 8 8
      tests/TestCase/Utility/LogTest.php

+ 1 - 1
docs/README.md

@@ -61,7 +61,7 @@ Entity:
 * [Enum](Entity/Enum.md)
 
 Utility:
-* [Log](Utility/Log.md)
+* [FileLog](Utility/FileLog.md)
 
 ## Basic enhancements of the core
 

+ 6 - 6
docs/Utility/Log.md

@@ -1,4 +1,4 @@
-# Log
+# FileLog
 
 Log class let's you write logs into custom log files.
 
@@ -29,19 +29,19 @@ With above approach, we have multiple issues:
 
 Or you hack it with doing something like setting configurations in `bootstrap.php` and use scope to log data. But each time you start new project you have to remember to copy paste that config and use in your project in order to write data into custom log files.
 
-#### With `Tools\Utility\Log` class:
+#### With `Tools\Utility\FileLog` class:
 
 You can directly pass data to log and filename to write the data into.
 
 ##### Usage:
 
 ```php
-use Tools\Utility\Log;
+use Tools\Utility\FileLog;
 
-Log::write("Something didn't work!", 'my_file');
+FileLog::write("Something didn't work!", 'my_file');
 
 // Somewhere else in any file
-Log::write([
+FileLog::write([
     'user' => [
         'id' => '1',
         'name' => 'John',
@@ -50,6 +50,6 @@ Log::write([
 ], 'user_data');
 ```
 
-That's it! Above will create two separate files in `log/` directory named `my_file.log` and `user_data.log` store data into which we passed in first argument. By default if you don't pass the `$filename` in second param in `Log::write` method, it will create `custom_log.log` file.
+That's it! Above will create two separate files in `log/` directory named `my_file.log` and `user_data.log` store data into which we passed in first argument. By default if you don't pass the `$filename` in second param in `FileLog::write` method, it will create `custom_log.log` file.
 
 You can write string, array, objects, etc into log files. It will pretty print your array/object so it's more readable. Also, it will not duplicate records into `$level.log` file.

+ 1 - 1
src/Utility/Log.php

@@ -8,7 +8,7 @@ use Exception;
 /**
  * Wrapper class to log data into custom file(s).
  */
-class Log {
+class FileLog {
 
 	/**
 	 * Debug configuration.

+ 8 - 8
tests/TestCase/Utility/LogTest.php

@@ -4,12 +4,12 @@ namespace Tools\Test\Utility;
 
 use Exception;
 use Tools\TestSuite\TestCase;
-use Tools\Utility\Log;
+use Tools\Utility\FileLog;
 
 /**
- * LogTest class
+ * FileLogTest class
  */
-class LogTest extends TestCase {
+class FileLogTest extends TestCase {
 
 	/**
 	 * Default filename with path to use in test case.
@@ -64,7 +64,7 @@ class LogTest extends TestCase {
 			unlink(static::TEST_FILEPATH_STRING);
 		}
 
-		$result = Log::write('It works!', static::TEST_FILENAME_STRING);
+		$result = FileLog::write('It works!', static::TEST_FILENAME_STRING);
 
 		$this->assertTrue($result);
 		$this->assertFileExists(static::TEST_FILEPATH_STRING);
@@ -89,7 +89,7 @@ class LogTest extends TestCase {
 			unlink(static::TEST_FILEPATH_ARRAY2);
 		}
 
-		$result1 = Log::write(
+		$result1 = FileLog::write(
 			[
 				'user' => [
 					'id' => 1,
@@ -100,7 +100,7 @@ class LogTest extends TestCase {
 			static::TEST_FILENAME_ARRAY1
 		);
 
-		$result2 = Log::write(
+		$result2 = FileLog::write(
 			[
 				'user' => [
 					'id' => 2,
@@ -149,7 +149,7 @@ class LogTest extends TestCase {
 			// Do nothing
 		}
 
-		$result = Log::write($exception, static::TEST_FILENAME_OBJECT);
+		$result = FileLog::write($exception, static::TEST_FILENAME_OBJECT);
 
 		$this->assertTrue($result);
 		$this->assertFileExists(static::TEST_FILEPATH_OBJECT);
@@ -171,7 +171,7 @@ class LogTest extends TestCase {
 			unlink(static::TEST_DEFAULT_FILEPATH_STRING);
 		}
 
-		$result = Log::write('It works with default too!');
+		$result = FileLog::write('It works with default too!');
 
 		$this->assertTrue($result);
 		$this->assertFileExists(static::TEST_DEFAULT_FILEPATH_STRING);