Como utilizar os arquivos de log (servidor web, PHP) e como gerá-los, quais as configurações que afetam o comportamento da geração de log no PHP, como gerar mensagens melhores e arquiteturas comuns para manter e utilizar melhor o potencial dessas mensagens.
O vídeo da apresentação: https://www.youtube.com/watch?v=pGPyKxuUAAo
73. 1 <?php
2 ini_set('display_errors', 1);
3 error_reporting(E_ALL);
4
5 echo date('l').PHP_EOL;
6
7 date_default_timezone_set('America/Sao_Paulo');
8
9 echo date('l').PHP_EOL;
10
11 /**
12 * Output:
13 *
14 * PHP Warning: date(): It is not safe to rely on the system's
15 * timezone settings. You are *required* to use the date.timezone
16 * setting or the date_default_timezone_set() function.
17 * In case you used any of those methods and you are still getting
18 * this warning, you most likely misspelled the timezone identifier.
19 * We selected the timezone 'UTC' for now, but please set date.timezone
20 * to select your timezone. in date.php on line 5
21 *
22 * Saturday
23 * Saturday
24 */
75. 1 <?php
2 ini_set('display_errors', 1);
3 error_reporting(E_ALL);
4
5 include 'nao-existe.php';
6
7 /**
8 * Output:
9 *
10 * PHP Warning: include(nao-existe.php): failed to open stream:
11 * No such file or directory in warning.php on line 5
12 */
87. #!/bin/bash
[~/Desktop/erros/source] $ php exception.php
!
Fatal error: Uncaught exception 'Exception' with message 'Shit happens...' in /
Users/apascutti/Desktop/erros/source/exception.php on line 8
!
Exception: Shit happens... in /Users/apascutti/Desktop/erros/source/
exception.php on line 8
!
Call Stack:
0.0002 228584 1. {main}() /Users/apascutti/Desktop/erros/source/
exception.php:0
88. #!/bin/bash
[~/Desktop/erros/source] $ php exception.php
!
Fatal error: Uncaught exception 'Exception' with message 'Shit happens...' in /
Users/apascutti/Desktop/erros/source/exception.php on line 8
!
Exception: Shit happens... in /Users/apascutti/Desktop/erros/source/
exception.php on line 8
!
Call Stack:
0.0002 228584 1. {main}() /Users/apascutti/Desktop/erros/source/
exception.php:0
!
[~/Desktop/erros/source] $ tail example.log
[10-Jun-2014 00:35:19 America/Sao_Paulo] PHP Fatal error: Uncaught exception
'Exception' with message 'Shit happens...' in /Users/apascutti/exception.php:8
Stack trace:
#0 {main}
thrown in /Users/apascutti/exception.php on line 8
89. 1 <?php
2
3 ini_set('display_errors', 1);
4 ini_set('error_log', __DIR__.'/example.log');
5 error_reporting(-1);
6 date_default_timezone_set('America/Sao_Paulo');
7
8 try {
9 throw new Exception('Shit happens...');
10 } catch (Exception $e) {
11 throw new Exception('and hit the fan.', 14, $e);
12 }
90. #!/bin/bash
[~/apascutti] $ php exception.php
!
Fatal error: Uncaught exception 'Exception' with message 'Shit happens...' in /
Users/apascutti/exception.php on line 11
!
Exception: Shit happens... in /Users/apascutti/exception.php on line 9
!
Call Stack:
0.0002 229536 1. {main}() /Users/apascutti/exception.php:0
!
Exception: and hit the fan. in /Users/apascutti/exception.php on line 11
!
Call Stack:
0.0002 229536 1. {main}() /Users/apascutti/exception.php:0
97. 2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include() [<a href='function.include'>function.include</a>]: Failed
opening 'PHPUnit/Framework/TestCase.php' for inclusion (include_path='/home/nihon-store/www/nihon-store/shop/data/module:.:/usr/local/
php/5.2.17/lib/php:/opt/local/lib/php') on [/home/nihon-store/www/nihon-store/shop/data/class/SC_ClassAutoloader.php(120)] from
66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Fatal error(E_ERROR): Class 'PHPUnit_Framework_TestCase' not found on [/home/nihon-store/
www/nihon-store/shop/test/class/page/LC_Page_Test.php(35)] from 66.249.74.101 customer_id =
2014/01/10 23:41:41 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:47:58 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:54:15 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:07:48 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:13:57 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:20:08 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 05:10:51 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
98. 2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include() [<a href='function.include'>function.include</a>]: Failed
opening 'PHPUnit/Framework/TestCase.php' for inclusion (include_path='/home/nihon-store/www/nihon-store/shop/data/module:.:/usr/local/
php/5.2.17/lib/php:/opt/local/lib/php') on [/home/nihon-store/www/nihon-store/shop/data/class/SC_ClassAutoloader.php(120)] from
66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Fatal error(E_ERROR): Class 'PHPUnit_Framework_TestCase' not found on [/home/nihon-store/
www/nihon-store/shop/test/class/page/LC_Page_Test.php(35)] from 66.249.74.101 customer_id =
2014/01/10 23:41:41 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:47:58 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:54:15 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:07:48 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:13:57 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:20:08 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 05:10:51 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
99. 2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include() [<a href='function.include'>function.include</a>]: Failed
opening 'PHPUnit/Framework/TestCase.php' for inclusion (include_path='/home/nihon-store/www/nihon-store/shop/data/module:.:/usr/local/
php/5.2.17/lib/php:/opt/local/lib/php') on [/home/nihon-store/www/nihon-store/shop/data/class/SC_ClassAutoloader.php(120)] from
66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Fatal error(E_ERROR): Class 'PHPUnit_Framework_TestCase' not found on [/home/nihon-store/
www/nihon-store/shop/test/class/page/LC_Page_Test.php(35)] from 66.249.74.101 customer_id =
2014/01/10 23:41:41 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:47:58 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:54:15 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:07:48 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:13:57 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:20:08 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 05:10:51 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
Data
100. 2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include() [<a href='function.include'>function.include</a>]: Failed
opening 'PHPUnit/Framework/TestCase.php' for inclusion (include_path='/home/nihon-store/www/nihon-store/shop/data/module:.:/usr/local/
php/5.2.17/lib/php:/opt/local/lib/php') on [/home/nihon-store/www/nihon-store/shop/data/class/SC_ClassAutoloader.php(120)] from
66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Fatal error(E_ERROR): Class 'PHPUnit_Framework_TestCase' not found on [/home/nihon-store/
www/nihon-store/shop/test/class/page/LC_Page_Test.php(35)] from 66.249.74.101 customer_id =
2014/01/10 23:41:41 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:47:58 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:54:15 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:07:48 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:13:57 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:20:08 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 05:10:51 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
Arquivo
101. 2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include() [<a href='function.include'>function.include</a>]: Failed
opening 'PHPUnit/Framework/TestCase.php' for inclusion (include_path='/home/nihon-store/www/nihon-store/shop/data/module:.:/usr/local/
php/5.2.17/lib/php:/opt/local/lib/php') on [/home/nihon-store/www/nihon-store/shop/data/class/SC_ClassAutoloader.php(120)] from
66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Fatal error(E_ERROR): Class 'PHPUnit_Framework_TestCase' not found on [/home/nihon-store/
www/nihon-store/shop/test/class/page/LC_Page_Test.php(35)] from 66.249.74.101 customer_id =
2014/01/10 23:41:41 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:47:58 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:54:15 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:07:48 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:13:57 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:20:08 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 05:10:51 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
Severidade
102. 2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Warning(E_WARNING): include() [<a href='function.include'>function.include</a>]: Failed
opening 'PHPUnit/Framework/TestCase.php' for inclusion (include_path='/home/nihon-store/www/nihon-store/shop/data/module:.:/usr/local/
php/5.2.17/lib/php:/opt/local/lib/php') on [/home/nihon-store/www/nihon-store/shop/data/class/SC_ClassAutoloader.php(120)] from
66.249.74.101
2014/01/10 23:28:24 [/shop/test/TestSuite.php] Fatal error(E_ERROR): Class 'PHPUnit_Framework_TestCase' not found on [/home/nihon-store/
www/nihon-store/shop/test/class/page/LC_Page_Test.php(35)] from 66.249.74.101 customer_id =
2014/01/10 23:41:41 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:47:58 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/10 23:54:15 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:07:48 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:13:57 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 04:20:08 [/shop/test/createEcCubeData-v25.php] Warning(E_WARNING): getopt() [<a href='function.getopt'>function.getopt</a>]:
No support for long options in this build on [/home/nihon-store/www/nihon-store/shop/test/createEcCubeData-v25.php(119)] from
66.249.74.101
2014/01/11 05:10:51 [/shop/test/TestSuite.php] Warning(E_WARNING): include(PHPUnit/Framework/TestCase.php) [<a
href='function.include'>function.include</a>]: failed to open stream: No such file or directory on [/home/nihon-store/www/nihon-store/shop/
data/class/SC_ClassAutoloader.php(120)] from 66.249.74.101
Mensagem