Code Monkey home page Code Monkey logo

wp-debug-logger's People

Contributors

andrewwoods avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wp-debug-logger's Issues

Create a level constant for wp-config.php

Allow my plugin user to specify a constant in their wp-config to determine the minimum log level for writing. On production i'd recommend "error", then notice for "staging", then "debug" in their development environment

Respect the WP_DEBUG and WP_DEBUG_LOG constants

Only try to write the wp-content/debug.log file when WP_DEBUG and WP_DEBUG_LOG constants are both true. Without respecting these constants, the users logfile will needlessly fill up. This would be bad in a production environment. Users should have confidence in their settings.

Add ability to specify channels

The wp-content/debug.log will represent the syslog.

Add an email channel for when things go really bad. At least one person should get emailed, maybe more.

Other possible channels:

  • DIscord
  • Slack
  • Twilio via SMS
  • Vonage via SMS

Update README.md with debug instructions

Provide instructions on how to update wp-config.php constants for normal local debugging. Make it easy for developers so they don't have to search the web for debugging instructions.

Create a Log method for var_dump data

On occassion, you need to var_dump a variable with an unknown structure. Passing the var_dump value to one of the standard log level methods will add a level of structure - which is not ideal. Create a separate method named dump.

Add support for passing a WP_Error object to $context in log methods

Describe the problem you want to solve

Problem: The $context parameter in the log methods only supports passing an array of data.

Background:
It is not currently possible to (sanely) pass a WP_Error object to the $context parameter in any of the log methods outside of passing it inside an array in order to adhere to the typehinting rules.

A central feature of error logging in WordPress is the ability to leverage the WP_Error object to log errors against, and I would think a WordPress logger utility should handle for that eventuality as elegantly as it can.

Describe the solution you'd like

Ideally, $context would be allowed to accept mixed types: either an array or WP_Error object. Naturally, such a change would mean the typehinting on the $context parameter in all of the logging method signatures would have to be dropped.

Describe alternatives you've considered

I've been using a sort of simplified version of a logger similar to this one in private and commercial WordPress products for years. When our $data parameter (similar in use to $context) was initially introduced, it was blind to the input, I think it just supported any kind of input and was output as a string similarly to how the new dump() method introduced in #6 works.

At a certain point, DRY principles necessitated adding WP_Error support to handle for first- and third-party integrations that returned WP_Error object. This feature was initially implemented to support WP_Error objects containing just a single error, though it was later expanded to handle for WP_Error objects containing multiple different errors that could be "collated" together into a cohesive string of output.

Additional context

Changing $context to accept something other than an array (and dropping the array typehints) would constitute a break in backward compatibility for anyone extending the Log or Logger classes.

Create a Log method for print_r data

On occassion, you need to print_r a variable with an unknown structure. Passing the print_r value to one of the standard log level methods will add a level of structure - which is not ideal. Create a separate method named print.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.