Commit Graph

77 Commits

Author SHA1 Message Date
Eric Espie
fac454595a removing meaningless information 2021-10-22 10:10:14 +02:00
bruno-ds
9e1f5a1b63 N°4261 - ExceptionLog restore Portal log level to Error as for iTop 2.7 (no more BC break)
- default level is now Error,
 - for "write in DB": each level (including error) are ignored by default
2021-10-21 16:18:27 +02:00
bruno-ds
5e2f8a4ea6 N°4261 - ExceptionLog: improve readability 2021-10-21 11:07:44 +02:00
bruno-ds
62f7eca0a8 N°4261 - Log in db: change default level.
In order to preserve the existing behavior: not EventIssue creation (unless configured otherwise).
2021-10-21 11:07:44 +02:00
Pierre Goiffon
0e14be8b15 N°4261 Refactor ExceptionLog (#239)
Doing a code review with Bruno, we agreed to do some little refactoring :

* Level per exception class
  - Before the whole ExceptionLog::Log method was a total rewrite of its parent, with some code duplicates... not a good idea : we should better improve LogAPI to make other similar uses possible in the future !
  - The logic to get level from config must be in a GetMinLogLevel override
* Write to DB
  - Pull up this functionnality in LogAPI
  - Add a sCode parameter in GetLevelDefault

Doing this refactoring, I also improved :

* Test the attributes set when creating the EventIssue object : during my dev I had crashes because I didn't filled all the mandatory fields... Having a PHPUnit test checking this will prevent future bugs to happen if attributes are modified in the class or in the object creation method
* Use Throwable instead of Exception : this was added in PHP 7.0 and will allow to catch both Exception and Error
* Because we need to have 2 statements on the same line in \Combodo\iTop\Test\UnitTest\Core\Log\ExceptionLogTest::testLogInFile, I modified the editorConfig file to allow disabling the formatter using comments.
2021-10-20 16:01:08 +02:00
Pierre Goiffon
ef6d7925fc Log : always log the same structure, and add a delimiter at the end
This will allow to parse the logs more easily !
2021-10-20 15:16:57 +02:00
Pierre Goiffon
c3d23981fb 💡 Document limitation in \LogAPI::GetConfig 2021-09-30 14:45:06 +02:00
acognet
e97a266c44 N°3946 - LogAPI : log config parameters aren't used when logging in the setup wizard context 2021-09-23 09:19:54 +02:00
bruno-ds
c306c6e30d N°4261 - code review with @PirGoif 2021-09-21 16:38:10 +02:00
Pierre Goiffon
f0aaf21a79 💚 N°3002 Fix php-mock-objects notices
The error handler now checks if logger is enabled before doing anything
2021-09-21 12:01:42 +02:00
Molkobain
96e4ef68df Code conventions 2021-09-21 09:38:01 +02:00
bruno-ds
daf24d8cb3 N°4261 - implement feedbacks from the team
plus:
 - the entrypoint is now `LogException()` instead of `FromException()` which sounded more like a factory and less like an active method.
 - merge conflicting commit with @molkobain (CC fix)
 - remove the writing of the exception object in the error.log context (adding it was an error, it's way too verbose!!).
   - Technical note: The context is still used to propagate the exception across several call stack, so it now uses a less generic naming in order to avoid conflicts (see `ExceptionLog::CONTEXT_EXCEPTION`). another solution would have been to add a new parameter to `ExceptionLog::Log()`, but I didn't want to add constraint over the hypothetical evolution of the base class method.
2021-09-20 12:27:39 +02:00
bruno-ds
6e0d570d41 N°4261 - Portal exception logging: Add exception's file and line to the context.
plus:
 - the exception object is no more automatically added to the error.log context (it's way too verbose)
 - code cleanup (use constant instead of repeated strings)
 - ExceptionLog main method is now named `LogException` instead of `FromException`
2021-09-20 12:27:39 +02:00
Molkobain
6271a33fdb Code review: Fix code conventions 2021-09-16 14:53:40 +02:00
bruno-ds
d1721b0834 N°4261 -Fix CI
Try to repair an odd error in the CI:
> Fatal error: Uncaught Exception: Serialization of 'ReflectionClass' is not allowed

avoid instantiation in the provider, delay them to the actual test
2021-09-15 14:39:00 +02:00
bruno-ds
5d23a250ae N°4261 - New log handler dedicated to Exceptions & use of it in the portal's Exception listener
Such Exceptions are triggered with a Warning level and default the minimum default level in order to write in DB is above, so the behavior is not modified:
 - logs are written in errors.log (with a warning elvel instead of an error)
 - logs are not written in DB unless `log_level_min.write_in_db` is changed
2021-09-14 17:40:11 +02:00
Pierre Goiffon
d0ba84068d N°3002 Better log deprecated call location
Now logs file location when called by a function
2021-08-30 16:43:30 +02:00
Pierre Goiffon
d6d1a5cc23 N°3002 Fix undefined index notice in \DeprecatedCallsLog::DeprecatedNoticesErrorHandler 2021-08-30 15:58:55 +02:00
Molkobain
c475e66176 Add documentation 2021-08-12 09:35:14 +02:00
Pierre Goiffon
a742b6c610 🔊 N°3002 DeprecatedCallsLog error handler : add trigger_error message 2021-08-09 09:06:17 +02:00
Pierre Goiffon
72e628c5d5 💡 Reference in PHPDoc for \LogAPI::GetMinLogLevel 2021-08-06 17:39:34 +02:00
Pierre Goiffon
bf28602ae6 💡 Improve PHPDoc for \LogAPI::GetMinLogLevel 2021-08-06 17:37:56 +02:00
Pierre Goiffon
d335736cfc 🔊 N°3002 Add trigger_error to catch deprecated notices inside DeprecatedCallsLog
They are logged as WARNING level in \DeprecatedCallsLog::ENUM_CHANNEL_PHP_LIBMETHOD channel

Such deprecated notices are generated inside Symfony for example using @trigger_error(..., E_DEPRECATED).
Having such a log will help us migrate to the next lib version !
2021-08-06 17:13:24 +02:00
Molkobain
78af6fdc84 N°3944 - Add comment to explain the 2 similar IFs 2021-08-06 11:11:57 +02:00
Pierre Goiffon
d30871ac59 Revert "N°3002 Add trigger_error to catch deprecated notices inside DeprecatedCallsLog"
This reverts commit d247ea915d.
Will solve CI build errors... I will work in my own branch to tweak this !
2021-08-05 17:35:17 +02:00
Pierre Goiffon
d247ea915d N°3002 Add trigger_error to catch deprecated notices inside DeprecatedCallsLog
Such notices are generated inside Symfony for example using @trigger_error(..., E_DEPRECATED).
Having such a log will help us migrate to the next version !
2021-08-05 17:18:19 +02:00
denis.flaven@combodo.com
29967aa41a N°3944 - LogAPI : fix default log level in config when logging using a channel 2021-08-04 10:07:58 +02:00
Eric
a117906ff6 🎨 Add constant for cmdbsource log channel 2021-07-02 17:01:46 +02:00
Pierre Goiffon
0dc03de7b2 Log channels : switch 3.0.0 channels to constant also
Those channels constants were introduced in support/2.7 with 8259a79c
2021-06-29 11:59:34 +02:00
Pierre Goiffon
2a1e0b7429 Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	core/dbobject.class.php
#	core/log.class.inc.php
#	setup/compiler.class.inc.php
2021-06-28 08:58:34 +02:00
Pierre Goiffon
8259a79cd2 🎨 Factorize LogAPI channels value in LogChannels class 2021-06-25 17:13:35 +02:00
Pierre Goiffon
5db8bd06ba Merge remote-tracking branch 'origin/support/2.7' into develop
# Conflicts:
#	core/cmdbsource.class.inc.php
#	core/coreexception.class.inc.php
#	core/log.class.inc.php
2021-06-21 16:24:27 +02:00
Eric
0f5130611d Fix log API tests 2021-06-21 16:07:36 +02:00
Eric
a1271da74a N°3513 - ObjectFormManager : remove transaction 2021-06-21 15:03:17 +02:00
Pierre Goiffon
8f84c3b84b 🎨 LogAPI code formatting 2021-06-18 10:58:04 +02:00
Pierre Goiffon
d8e2a1cc7c Merge branch 'support/2.7' into develop
# Conflicts:
#	README.md
#	composer.json
#	composer.lock
#	core/cmdbsource.class.inc.php
#	core/dbobject.class.php
#	datamodels/2.x/combodo-db-tools/db_analyzer.class.inc.php
#	datamodels/2.x/combodo-db-tools/dbtools.php
#	datamodels/2.x/combodo-db-tools/dictionaries/zh_cn.dict.combodo-db-tools.php
#	datamodels/2.x/itop-attachments/dictionaries/zh_cn.dict.itop-attachments.php
#	datamodels/2.x/itop-core-update/dictionaries/zh_cn.dict.itop-core-update.php
#	dictionaries/zh_cn.dictionary.itop.core.php
#	dictionaries/zh_cn.dictionary.itop.ui.php
#	lib/composer/InstalledVersions.php
#	lib/composer/autoload_classmap.php
#	lib/composer/autoload_static.php
#	lib/composer/installed.php
#	lib/composer/platform_check.php
#	pages/ajax.render.php
#	pages/csvimport.php
#	setup/ajax.dataloader.php
#	setup/index.php
#	setup/setuputils.class.inc.php
#	test/application/UtilsTest.php
2021-06-14 16:19:56 +02:00
Pierre Goiffon
147916062b 🎨 Fix local variable names
Was copy/paste and wasn't consistent with the functionnality :/
2021-06-10 16:28:17 +02:00
Molkobain
1c2dcc7b9a Merge remote-tracking branch 'origin/support/2.7' into develop 2021-05-11 12:22:47 +02:00
Pierre Goiffon
87ba67225a 💡 Add since phpdoc tags for \DeadLockLog::Log 2021-04-16 08:36:21 +02:00
Pierre Goiffon
2ad3b3c27e 🎨 Fix \DeadLockLog::Log parameter name + PHPDoc
Thanks @Hipska !
2021-04-15 15:03:13 +02:00
Pierre Goiffon
a6d20ab648 N°3731 \DeprecatedCallsLog : always catch errors so that we won't crash the caller 2021-04-13 17:56:20 +02:00
Pierre Goiffon
7f4ef12c04 🐛 Fix \DeprecatedCallsLog::NotifyDeprecatedPhpMethod log message
This was bringed by #193
The stack trace wasn't used correctly :/ This is now fixed !

Sample message for deprecated PHP method call :
`2021-04-13 15:31:47 | Warning | Call to WebPage:outputCollapsibleSectionInit in  C:\...\itop-dev\sources\application\WebPage\AjaxPage.php#L170 (AjaxPage::output) | deprecated-php-method`

Log message for deprecated PHP file remains the same :
`2021-04-13 10:31:12 | Warning | C:\...\itop-dev\sources\application\WebPage\WebPage.php L32 including/requiring C:\...\itop-dev\core\coreexception.class.inc.php : Classes were moved to /application/exceptions | deprecated-file`
2021-04-13 15:38:38 +02:00
Pierre Goiffon
f6d9d0f08b N°3731 Log deprecated calls (#193)
* New DeprecatedCallsLog logger enabled directly in bootstrap so that we can use it in the most situations
* Default Log level is now DEBUG for dev env, ERROR for others
* Logs the caller and the deprecated method called, like :
`2021-04-06 10:52:25 | Warning | AjaxPage::output L2857 calling WebPage:outputCollapsibleSectionInit | deprecated-method`
* Sample file consumer
* Sample php consumer
2021-04-13 13:55:25 +02:00
Molkobain
8dd96ea636 Copyright year bump 2021-03-15 09:29:45 +01:00
Eric
761c2a46a3 N°3234 - Cron rework
* some timezone refactors occurred
2020-08-25 11:20:17 +02:00
Pierre Goiffon
336637a7a4 SetupLog : ease changing manually the default level
In setup no conf file available so the log_level_min config option cannot be read
A solution is to manually change this constant
2020-05-28 11:40:22 +02:00
Pierre Goiffon
0ffa2850ea Deadlock log : log inside a dedicated log file instead of creating an EventIssue object (#139)
First log implementation (75730ee) was creating EventIssue objects, and was rollbacking transaction if it exists

The new one has some benefits :

* always log one line by default in log/error.log, but details must be activated though config (channels `Deadlock-WaitTimeout` and `Deadlock-Found`)
* detailed logs are in a dedicated file (log/deadlock.log) : 
  - easier for our clients to get and share
  - has rotation by default
  - looking at the file size is a direct way to know if error happened
  - more compliant to industry standards !
* the transaction stays untouched, so that the consumer can do whatever it prefers
2020-05-14 17:49:05 +02:00
Pierre Goiffon
7ec7626aa0 N°2977 PHP Doc change 2020-05-04 18:13:40 +02:00
Pierre Goiffon
5d7582bb6f N°2977 LogAPI : restore default log level to OK, and really allow LEVEL_DEFAULT overloads
* Level was changed by mistake to trace with refactoring in 289171b9
Thanks @v-dumas !

* self wouldn't allow to override
see https://www.php.net/manual/fr/language.oop5.late-static-bindings.php
Thanks @bruno-ds !

* improve PHPDoc !
2020-05-04 16:55:46 +02:00
Pierre Goiffon
bf13f9fc8a N°2975 improve RotatingLogFileNameBuilder next cron occurrence computation 2020-04-30 08:41:55 +02:00