CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • PSR3 logger system log (4.5 not 5.0)
Pages: [1]

Author Topic: PSR3 logger system log (4.5 not 5.0)  (Read 735 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
PSR3 logger system log (4.5 not 5.0)
May 01, 2014, 12:49:18 pm
Just a quick update that we have introduced a civicrm_system_log in 4.5 using the PSR3 standard. The current use case is just logging IPNs as they come in for forensic purposes - but there are a bunch of other possibilities that could eventuate

More on PSR 3
http://www.sitepoint.com/logging-with-psr-3-to-improve-reusability/

PR is here

https://github.com/civicrm/civicrm-core/pull/3075
& here
https://github.com/civicrm/civicrm-packages/pull/60

Ticket is here
https://issues.civicrm.org/jira/browse/CRM-14494
(yes - it does turn out I was referencing the wrong ticket :-()

There is a test in
https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SystemTest.php

Preferred retrieval method is system_log.get api

Preferred logging method is

Code: [Select]
$log = new CRM_Utils_SystemLogger();
$log->log('alert', 'payment_notification processor_name=Payment_Express', $_REQUEST);[/code

although system.log api also works

Note that the alert levels follow the PSR3 standard. The second param should be something fairly standardised (for searching) although there is no specified standard. The _spec function on the system.log api gives a bit more about the 'special' params in the log table - basically 'hostname' & contact_id get their own field & the rest are stored in a json encoded array.

Any questions? Tim's you man - although unfortunately git blame thinks differently
« Last Edit: May 01, 2014, 12:52:00 pm by Eileen »
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: PSR3 logger system log (4.5 not 5.0)
May 01, 2014, 03:04:48 pm
Wooo!

FWIW, you can cut out a few more characters (and benefit autocomplete) with the sugary functions:

Code: [Select]
$log = new CRM_Utils_SystemLogger();
$log->alert('payment_notification processor_name=Payment_Express', $_REQUEST);

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • 5.0 Saloon »
  • PSR3 logger system log (4.5 not 5.0)

This forum was archived on 2017-11-26.