|
| 1 | +# BetterStack Logger |
| 2 | + |
| 3 | +BetterStack Logger is a powerful WordPress plugin that allows you to seamlessly integrate BetterStack with your WordPress site. Enhance your logging capabilities by sending error messages, post changes, user actions, and more directly to BetterStack. With easy configuration and flexible logging functions, this plugin is an essential tool for developers and site administrators looking to keep track of their site's activities. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Error Logging:** Capture and log WordPress errors directly to BetterStack. |
| 8 | +- **User Action Logging:** Log important user actions such as logins, registrations, and profile updates. |
| 9 | +- **Post Changes:** Monitor post creation, updates, and deletions. |
| 10 | +- **Plugin and Theme Activity:** Log plugin activations/deactivations and theme switches. |
| 11 | +- **Customizable Logging:** Use helper functions to log custom messages from anywhere in your codebase. |
| 12 | +- **Settings Page:** Easily configure the API key, enable or disable specific logging features via the WordPress admin panel. |
| 13 | +- **Support for `wp-config.php`:** Define your BetterStack API key in `wp-config.php` for additional security. |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +### From Your WordPress Dashboard |
| 18 | + |
| 19 | +1. Navigate to `Plugins` -> `Add New`. |
| 20 | +2. Search for `BetterStack Logger`. |
| 21 | +3. Click `Install Now`. |
| 22 | +4. Activate the plugin. |
| 23 | +5. Go to `Tools` -> `BetterStack Logger Settings` to configure the plugin. |
| 24 | + |
| 25 | +### Manual Installation |
| 26 | + |
| 27 | +1. Download the plugin from the [Plugin Releases](https://github.com/prolific-digital/betterstack-logger/releases). |
| 28 | +2. Upload the `betterstack-logger` directory to the `/wp-content/plugins/` directory. |
| 29 | +3. Activate the plugin through the `Plugins` menu in WordPress. |
| 30 | +4. Go to `Tools` -> `BetterStack Logger Settings` to configure the plugin. |
| 31 | + |
| 32 | +## Configuration |
| 33 | + |
| 34 | +### API Key |
| 35 | + |
| 36 | +To log messages to BetterStack, you need to set up your API key: |
| 37 | + |
| 38 | +1. Go to `Tools` -> `BetterStack Logger Settings`. |
| 39 | +2. Enter your BetterStack API key in the `API Key` field. |
| 40 | +3. Optionally, define the API key in your `wp-config.php` file using `BETTERSTACK_API_KEY`. |
| 41 | + |
| 42 | +### Logging Options |
| 43 | + |
| 44 | +- **Enable Error Logging:** Toggle to capture WordPress errors. |
| 45 | +- **Enable Event Logging:** Toggle to log user actions, post changes, and more. |
| 46 | + |
| 47 | +## Usage |
| 48 | + |
| 49 | +### Logging Custom Messages |
| 50 | + |
| 51 | +Use the following functions to log messages from anywhere in your code: |
| 52 | + |
| 53 | +```php |
| 54 | +// Log a custom message |
| 55 | +better_error_log('This is a custom error message.'); |
| 56 | + |
| 57 | +// Shorter version |
| 58 | +b_log('This is a quick log message.'); |
| 59 | +``` |
| 60 | + |
| 61 | +### Example: |
| 62 | + |
| 63 | +```php |
| 64 | +function my_custom_function() { |
| 65 | + // Perform some task |
| 66 | + // ... |
| 67 | + |
| 68 | + // Log a message |
| 69 | + better_error_log('Task completed successfully.'); |
| 70 | +} |
| 71 | + |
| 72 | +add_action('init', 'my_custom_function'); |
| 73 | +``` |
| 74 | + |
| 75 | +### Available Functions |
| 76 | + |
| 77 | +- `better_error_log($message)`: Logs a custom message to BetterStack. |
| 78 | +- `b_log($message)`: Shorthand function to log a custom message to BetterStack. |
| 79 | + |
| 80 | +## Frequently Asked Questions |
| 81 | + |
| 82 | +Can I define the API key in `wp-config.php`? |
| 83 | + |
| 84 | +Yes! For added security, you can define your API key in `wp-config.php` using: |
| 85 | + |
| 86 | +```php |
| 87 | +define('BETTERSTACK_API_KEY', 'your-api-key-here'); |
| 88 | +``` |
| 89 | + |
| 90 | +What types of events can I log with BetterStack Logger? |
| 91 | + |
| 92 | +You can log errors, user actions (e.g., logins, registrations), post changes (e.g., creation, updates, deletions), plugin activations/deactivations, theme switches, and custom messages. |
| 93 | + |
| 94 | +## Support |
| 95 | + |
| 96 | +If you need help or have any questions, feel free to reach out to us: |
| 97 | + |
| 98 | +- Visit our [Support Page](https://prolificdigital.notion.site/BetterStack-Logger-c0cc4526efd049c09b77965bf3ecc28e) |
| 99 | + |
0 commit comments