Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 4e4296b

Browse files
committed
✨ add log_as() function
Signed-off-by: otengkwame <[email protected]>
1 parent 89e0a9c commit 4e4296b

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

framework/core/Common.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,60 @@ function log_message($level, $message)
470470
}
471471
}
472472

473+
474+
// ------------------------------------------------------------------------
475+
476+
if ( ! function_exists('log_as'))
477+
{
478+
/**
479+
* An implementation of the function above
480+
*
481+
* We use this to access the very common logs
482+
* like user, app, and error messages to be logged.
483+
*
484+
* @param string the error level: 'error', 'debug' or 'info'
485+
* @param string the error message
486+
* @return void
487+
*/
488+
function log_as()
489+
{
490+
$log = new class {
491+
492+
// Log levels available
493+
// 'USER' => '1',
494+
// 'APP' => '2',
495+
// 'ERROR' => '3',
496+
// 'INFO' => '4',
497+
// 'DEBUG' => '5',
498+
// 'ALL' => '6'
499+
public function app($message)
500+
{
501+
log_message('app', $message);
502+
503+
return $message;
504+
}
505+
506+
public function user($message)
507+
{
508+
log_message('user', $message);
509+
510+
return $message;
511+
}
512+
513+
public function error($message)
514+
{
515+
log_message('error', $message);
516+
517+
return $message;
518+
}
519+
520+
};
521+
522+
return $log;
523+
524+
}
525+
}
526+
473527
// ------------------------------------------------------------------------
474528

475529
if ( ! function_exists('set_status_header'))

0 commit comments

Comments
 (0)