Commit Graph

55 Commits

Author SHA1 Message Date
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
toddlahman 157c50df0a return boolean log add and clear method result 2016-04-12 23:46:30 -07:00
Fredrik Forsmo bb19615029 Improve docblock comments in various WC_* classes
* Added comments to various methods
* Fixed various properties comments and param types
2016-01-06 16:24:47 +01:00
Nicola Mustone c9da4f928a check if ABSPATH is defined 2015-11-06 10:22:19 +01:00
Claudio Sanches 5893875b0c Removed period for file headers 2015-11-03 11:53:50 -02:00
Claudio Sanches 9e41552342 Removed all "@return void" 2015-07-16 16:55:48 -03:00
Patrick Garman fb84486798 Update WC_Logger to include actions on add & clear methods
This allows for easy integrating with third party logging services.
2015-07-10 14:26:30 -05:00
Alexander Concha 7896b49684 fclose requires a resource, not a string. 2015-06-01 12:58:06 +01:00
Scrutinizer Auto-Fixer 19f660171e Scrutinizer Auto-Fixes
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
2015-01-23 14:37:20 +00:00