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 f1aeb50c
authored
Aug 31, 2024
by
irul
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add log with addtional arguments
1 parent
6e9a6e9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
Logger.php
example.php
Logger.php
View file @
f1aeb50
...
...
@@ -86,7 +86,14 @@ class Logger
public
function
log
(
$string
)
{
$log_source
=
sprintf
(
"%s:%d"
,
basename
(
debug_backtrace
()[
0
][
'file'
]),
debug_backtrace
()[
0
][
'line'
]);
$this
->
do_write
(
$string
,
$log_source
);
$args
=
func_get_args
();
if
(
count
(
$args
)
>
1
)
{
array_shift
(
$args
);
$log_string
=
vsprintf
(
$string
,
$args
);
}
else
{
$log_string
=
$string
;
}
$this
->
do_write
(
$log_string
,
$log_source
);
}
/*
...
...
example.php
View file @
f1aeb50
...
...
@@ -8,3 +8,4 @@ require_once 'Logger.php';
/* Define log path and log filename */
$logger
=
Logger
::
get_logger
(
'./logs'
,
'my-log'
);
$logger
->
log
(
"set log path and filename"
);
$logger
->
log
(
"log with addtional arguments: %s, %s"
,
"msg1"
,
"msg2"
);
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