Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
irul
/
php-logger
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 58ea95a3
authored
Aug 31, 2024
by
irul
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add specific functions for each level
1 parent
a606612c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
3 deletions
Logger.php
Logger.php
View file @
58ea95a
...
...
@@ -86,14 +86,52 @@ class Logger
public
function
log
(
$string
)
{
$log_source
=
sprintf
(
"%s:%d"
,
basename
(
debug_backtrace
()[
0
][
'file'
]),
debug_backtrace
()[
0
][
'line'
]);
$log_string
=
call_user_func_array
(
"Logger::get_message"
,
func_get_args
());
$this
->
do_write
(
$log_string
,
$log_source
,
"info"
);
}
/* Log Debug */
public
function
debug
(
$string
)
{
$log_source
=
sprintf
(
"%s:%d"
,
basename
(
debug_backtrace
()[
0
][
'file'
]),
debug_backtrace
()[
0
][
'line'
]);
$log_string
=
call_user_func_array
(
"Logger::get_message"
,
func_get_args
());
$this
->
do_write
(
$log_string
,
$log_source
,
"debug"
);
}
/* Log Info */
public
function
info
(
$string
)
{
$log_source
=
sprintf
(
"%s:%d"
,
basename
(
debug_backtrace
()[
0
][
'file'
]),
debug_backtrace
()[
0
][
'line'
]);
$log_string
=
call_user_func_array
(
"Logger::get_message"
,
func_get_args
());
$this
->
do_write
(
$log_string
,
$log_source
,
"info"
);
}
/* Log Warning */
public
function
warning
(
$string
)
{
$log_source
=
sprintf
(
"%s:%d"
,
basename
(
debug_backtrace
()[
0
][
'file'
]),
debug_backtrace
()[
0
][
'line'
]);
$log_string
=
call_user_func_array
(
"Logger::get_message"
,
func_get_args
());
$this
->
do_write
(
$log_string
,
$log_source
,
"warn"
);
}
/* Log Error */
public
function
error
(
$string
)
{
$log_source
=
sprintf
(
"%s:%d"
,
basename
(
debug_backtrace
()[
0
][
'file'
]),
debug_backtrace
()[
0
][
'line'
]);
$log_string
=
call_user_func_array
(
"Logger::get_message"
,
func_get_args
());
$this
->
do_write
(
$log_string
,
$log_source
,
"error"
);
}
/* Format Message */
private
function
get_message
(
$string
)
{
$args
=
func_get_args
();
if
(
count
(
$args
)
>
1
)
{
array_shift
(
$args
);
$
log_string
=
vsprintf
(
$string
,
$args
);
$
message
=
vsprintf
(
$string
,
$args
);
}
else
{
$
log_string
=
$string
;
$
message
=
$string
;
}
$this
->
do_write
(
$log_string
,
$log_source
,
"info"
)
;
return
$message
;
}
/*
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment