Skip to content

Skvare/com.skvare.logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Skvare Logger – CiviCRM Extension

Overview

Skvare Logger provides a lightweight logging utility for CiviCRM that allows developers to write structured logs into separate, monthly-rotated log files. These logs are stored in the same directory used by CiviCRM for configuration and logs, but remain independent from core CiviCRM error logging.

This is useful for:

  • Debugging specific features (mailings, payments, integrations)
  • Auditing background jobs or cron processes
  • Capturing structured debug output without polluting the main CiviCRM logs

Features

  • Singleton-based logger (CRM_Logger)
  • Separate log files per feature/type
  • Automatic monthly rotation (YYYYMM)
  • Logs stored in CiviCRM ConfigAndLog directory
  • Supports web and CLI execution
  • Optional IP address logging
  • Captures calling function, file, and line number

Installation

  1. Place the extension in your CiviCRM extensions directory:

    com.skvare.logger
    
  2. Enable the extension from:

    • Administer » System Settings » Extensions

No additional configuration is required.


Usage

Basic Example

$logger = CRM_Logger::singleton();
$logger->write('mailing', print_r($params, TRUE));

This will create (or append to) a file similar to:

ConfigAndLog/mailing202512.log

Including a Custom Message Only

CRM_Logger::singleton()->write('payment', 'Duplicate transaction detected');

Disable IP Logging

CRM_Logger::singleton()->write('cron', 'Job started', FALSE);

Log File Format

Each log entry includes:

  • Timestamp
  • Unique request ID (if available)
  • Calling function
  • File name and line number
  • IP address (optional)
  • Custom message content

Example output:

Dec 9th 14:35:18 - 8f823a7d
 - civicrm_api3_mailing_send, /CRM/Mailing/BAO/Mailing.php (412)
 from 192.168.1.10
Array
(
    [contact_id] => 123
    [status] => sent
)

Log File Location

All log files are written to:

[CiviCRM ConfigAndLog Directory]

Example:

sites/default/files/civicrm/ConfigAndLog/

Best Practices

  • Use meaningful log file names (mailing, payment, cron, integration)
  • Avoid logging sensitive data (credit cards, passwords, tokens)
  • Use print_r($data, TRUE) or json_encode() for structured data
  • Remove or reduce logging in production environments where appropriate

CiviCRM Compatibility

  • Tested with CiviCRM 5.45+
  • Compatible with Drupal, WordPress, and Joomla installs
  • Safe for CLI, cron, and web requests

License

AGPL-3.0


Maintainer

Skvare Website: https://www.skvare.com

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages