Skip to content

Commit

Permalink
Merge pull request #168 from ryanwelcher/feature/debug-log-action
Browse files Browse the repository at this point in the history
Adding custom action to AADSSO::debug_log
  • Loading branch information
psignoret authored Feb 12, 2018
2 parents 62e09d9 + f81a2ed commit e247766
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions aad-sso-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,20 @@ function print_login_link() {
* If there are multiple lines in the message, they will each be emitted as a log line.
*/
public static function debug_log( $message, $level = 0 ) {

/**
* Fire an action when logging.
*
* This allows external services to tie into these logs. We're adding it here so this can be used in prod for services such as Stream
*
* @since 0.6.2
*
* @param string $message The message being logged.
*/
do_action( 'aadsso_debug_log', $message );

// AADSSO_DEBUG and AADSSO_DEBUG_LEVEL are already defined.
if ( AADSSO_DEBUG && AADSSO_DEBUG_LEVEL >= $level ) {
if ( FALSE === strpos( $message, "\n" ) ) {
if ( false === strpos( $message, "\n" ) ) {
error_log( 'AADSSO: ' . $message );
} else {
$lines = explode( "\n", str_replace( "\r\n", "\n", $message ) );
Expand Down

0 comments on commit e247766

Please sign in to comment.