Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mjwshared
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
mjwshared
Commits
77723b42
Commit
77723b42
authored
1 year ago
by
mattwire
Browse files
Options
Downloads
Patches
Plain Diff
Add generic Logger class
parent
92efe9ba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Civi/MJW/Logger.php
+75
-0
75 additions, 0 deletions
Civi/MJW/Logger.php
with
75 additions
and
0 deletions
Civi/MJW/Logger.php
0 → 100644
+
75
−
0
View file @
77723b42
<?php
namespace
Civi\MJW
;
/**
* Abstracts the Civi::log class so that we:
* - Don't have to specify channel each time we log.
* - Automatically log the entityID/name if provided.
*/
class
Logger
{
/**
* The Log channel
*
* @var string
*/
private
string
$logChannel
=
''
;
/**
* The entityID/Name
*
* @var string
*/
private
string
$logEntity
=
''
;
public
function
__construct
(
string
$logChannel
,
string
$logEntity
)
{
$this
->
logChannel
=
$logChannel
;
$this
->
logEntity
=
$logEntity
;
}
/**
* Log an info message with payment processor prefix
* @param string $message
*
* @return void
*/
public
function
logInfo
(
string
$message
)
{
$this
->
log
(
'info'
,
$message
);
}
/**
* Log an error message with payment processor prefix
*
* @param string $message
*
* @return void
*/
public
function
logError
(
string
$message
)
{
$this
->
log
(
'error'
,
$message
);
}
/**
* Log a debug message with payment processor prefix
*
* @param string $message
*
* @return void
*/
public
function
logDebug
(
string
$message
)
{
$this
->
log
(
'debug'
,
$message
);
}
/**
* @param string $level
* @param string $message
*
* @return void
*/
private
function
log
(
string
$level
,
string
$message
)
{
$channel
=
$this
->
logChannel
;
$prefix
=
$channel
.
'('
.
$this
->
logEntity
.
'): '
;
\Civi
::
log
(
$channel
)
->
$level
(
$prefix
.
$message
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment