Commit Graph

63 Commits

Author SHA1 Message Date
Rami Yushuvaev 0087536296 i18n: Simpler translation string with placeholders
Replace:

`WC_Logger::log was called with an invalid level "%s".`

With:

`%1$s was called with an invalid level "%2$s".`
2017-08-16 00:22:46 +03:00
Rami Yushuvaev 7ce117a0ca i18n: Simpler translation string with placeholders
Replace:

`The provided handler <code>%s</code> does not implement WC_Log_Handler_Interface.`

With:

`The provided handler %1$s does not implement %2$s.`
2017-08-15 14:48:42 +03:00
David Marín f421939a3e Add new filter woocommerce_logger_log_message
It replicates the filter for the deprecated add logger function in the equivalent log function.
2017-05-30 09:55:10 +02:00
Mike Jolley d3666738d8 Merge branch 'pr/15069' 2017-05-23 18:56:58 +01:00
Boro Sitnikovski d302e18a9b Rename `informational` to `info` in the phpdoc 2017-05-18 10:32:25 +02:00
Rasmus Bengtsson 185934fad9 Fix phpdoc to include params and correct types 2017-05-15 13:50:52 +02:00
Mike Jolley 7269fde94f Moved reg handlers 2017-04-25 13:51:52 +01:00
mdrahul 521ad697b0 fix Invalid argument supplied error, ref #14615 2017-04-22 17:24:30 +05:30
Claudio Sanches 59c2849736 Changed version 2.7 to 3.0 2017-03-15 13:36:53 -03:00
Jon Surrell 65b5e4181f Use __METHOD__ over "{$class}::{$method}" 2017-01-24 23:09:24 +01:00
Jon Surrell 2bd8b6efbc Validate handlers implement WC_Log_handler_Interface
Add tests for interface validation.
2017-01-24 23:07:58 +01:00
Jon Surrell 72f4bcc292 Protect WC_Logger::should_handle
This method should not be public. It is not part of WC_Logger_Interface, and leaving it
public could cause problems
2017-01-23 19:59:01 +01:00
Jon Surrell 144ea5d5ab Include WC_Logger_Interface on startup 2017-01-14 17:58:24 +01:00
Jon Surrell bd090749ec Add WC_Logger_Interface
`class WC_Logger implements WC_Logger_Interface`.

The built-in logger can be replaced "globally" (when
provided via `wc_get_logger`) by using the filter
`woocommerce_logging_class`. This interface should make replacing
`WC_Logger` easier and safer.
2017-01-14 17:43:15 +01:00
Jon Surrell 5d7665671c Remove WC_Logger::remove
This method was added post 2.6 and does not need to be maintained/deprecated.
Remove related test.
2017-01-13 06:48:57 +01:00
Jon Surrell 78a6ed4d44 Restore remove and clear functionality to WC_Logger
Maintain backwards compatibility of removing or clearing files.
2017-01-12 22:13:42 +01:00
Jon Surrell 4cf86ef346 Use constants over settings to configure logger
Settings have been removed.
WC_LOG_THRESHOLD and WC_LOG_HANDLER constants have been added.
2016-12-29 11:58:43 +01:00
Jon Surrell c633b07f73 Fix style 2016-12-29 11:58:43 +01:00
Jon Surrell 4b13e3b053 Do not deprecate WC_Logger::add 2016-12-29 11:58:43 +01:00
Jon Surrell e4d5886427 Replace log `tag` with log `source` 2016-12-29 11:58:43 +01:00
Jon Surrell 5700043e6d Deprecate wc_get_log_file_path
wc_get_log_file_path moves into `WC_Log_Handler_File` class as a static
method.
Update deprecations and version info.
2016-12-29 11:58:43 +01:00
Jon Surrell 665e8ccfc6 Improve doc comments and access. 2016-12-29 11:58:43 +01:00
Jon Surrell f908a0181c Improve deprecation messages for WC_Logger
clear and remove *do* have alternatives. They have essentially
been moved to the file handler.
2016-12-29 11:58:43 +01:00
Jon Surrell 6068f681d3 Use 'notice' as level for deprecated WC_Logger::add messages.
Notice is the default (and recommended) threshold for production sites. Using
info, which is below notice, would result in ::add messages to be filtered by
default. This would be a confusing experience for users calling the deprecated
function and expecting a log.
2016-12-29 11:58:43 +01:00
Jon Surrell 88836b9cca Drop WP_DEBUG override threshold. Improve logger tests.
This may be unexpected behavior for a user, their level is overridden with no
way to change it. It also greatly complicates testing default thresholds.

Dependency on WC_Log_Handler_File has been removed from logger tests.
2016-12-29 11:58:43 +01:00
Jon Surrell 2626c5b3af Accept explicit handlers and threshold in WC_Logger 2016-12-29 11:58:43 +01:00
Jon Surrell 2945b4755f Add more information about log levels 2016-12-29 11:58:43 +01:00
Jon Surrell 85fa9df7fe Drop "bubbling" support for logs
The concept of bubbling or consuming logs has little benefit for our use case.
Drop support for bubbling and simplify logging.
2016-12-29 11:58:43 +01:00
Jon Surrell 4f77954bc7 Move log levels to independent class 2016-12-29 11:58:43 +01:00
Jon Surrell 822981c009 Improve handle signature
The signature of WC_Log_Handler::handle mirrors log messages which is more intuitive.
Method docblocks have also been improved and are more complete.
2016-12-29 11:58:42 +01:00
Jon Surrell 722b288b79 Remove _ from private/protected properties 2016-12-29 11:58:42 +01:00
Jon Surrell b5cebcab6c Fix scrutinizer issues 2016-12-29 11:58:42 +01:00
Jon Surrell c5c0563f7c Restore deprecated functions WC_Logger::clear & WC_Logger::remove
Also updates clear test to supply required argument.
2016-12-29 11:58:42 +01:00
Jon Surrell 44ea69c579 Adds tests for bubbling, etc.
Add tests teardown to cleanup log files
Fix errors in log handlers
2016-12-29 11:58:42 +01:00
Jon Surrell 0e0433195d Add logic for log level filtering to `WC_Log_Handler`. 2016-12-29 11:58:42 +01:00
Jon Surrell 9a0efcfe55 Add abstract WC_Log_Handler class
Abstract base class is implemented with default formatting implementations.
`$timestamp` has been added to the `WC_Log_Handler::handle` implementation. This ensures all handlers are passed the same timestamp for the same message.
`_legacy` context has been added to `WC_Log_Handler_File` to ensure handle deprecated `WC_Logger::add` provides the same log entries as before.

Fix CS problems.
2016-12-29 11:58:42 +01:00
Jon Surrell d9dcabf8f2 WC_Logger registers and delegates logging to handlers 2016-12-29 11:58:42 +01:00
David Marín 22229d1e2e Fix space between parenthesis 2016-09-15 21:43:56 +02:00
David Marín 3ab087212b Update class-wc-logger.php 2016-09-15 11:04:35 +02:00
David Marín d74e4e27a7 Update class-wc-logger.php 2016-09-14 13:28:28 +02:00
Claudio Sanches e72af424ac Check if FS_CHMOD_FILE is defined #11901 2016-09-13 18:38:16 -03:00
Mike Jolley 4d041b2ce2 chmod file when closed. 2016-09-12 23:37:02 +01:00
Rasmus 9e8670015e Make WC_Logger follow FS_CHMOD_FILE when file is created
When WC_Logger creates a file it should use the permissions defined in FS_CHMOD_FILE

See https://codex.wordpress.org/Editing_wp-config.php#Override_of_default_file_permissions
2016-09-12 12:59:18 +02:00
Aristeides Stathopoulos f2730eea02 WordPress.WhiteSpace.ControlStructureSpacing.BlankLineAfterEnd 2016-08-27 08:57:05 +03:00
Mike Jolley 922ba0337f Fix removal and tweak buttons 2016-08-02 14:42:27 +01:00
toddlahman 26353d7099 added remove method to logger class, and delete GeoIP Log button to tools 2016-07-02 23:16:11 -07:00
Mike Jolley a60b03baa9 Log close method. Fixes unit tests. 2016-04-19 16:56:43 +01:00
Mike Jolley f47a1de108 Close file if it's already open before clear 2016-04-19 16:31:36 +01:00
Mike Jolley ab61975357 Tweak returns 2016-04-19 14:00:40 +01:00
toddlahman 6003fb3303 ftruncate failed at times, so fopen() in w mode used instead. 2016-04-15 21:26:19 -07:00