Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
FNSO
I-FAIR IR
Circe Php Client
Commits
3d21f63f
Commit
3d21f63f
authored
May 21, 2021
by
Mickael Desfrenes
Browse files
add LogEntry class
parent
9dc95366
Changes
3
Hide whitespace changes
Inline
Side-by-side
composer.json
View file @
3d21f63f
...
...
@@ -10,7 +10,7 @@
}
},
"require"
:
{
"php"
:
">=7.
0.0
"
,
"php"
:
">=7.
4
"
,
"ext-json"
:
"*"
,
"ext-curl"
:
"*"
},
...
...
src/Certic/Circe/JobResult.php
View file @
3d21f63f
...
...
@@ -37,7 +37,7 @@ class JobResult
foreach
(
$lines
as
$line
){
$entry
=
json_decode
(
$line
,
true
);
if
(
$entry
){
yield
$entry
;
yield
new
LogEntry
(
$entry
)
;
}
}
}
...
...
src/Certic/Circe/LogEntry.php
0 → 100644
View file @
3d21f63f
<?php
declare
(
strict_types
=
1
);
namespace
Certic\Circe
;
class
LogEntry
{
const
LEVEL_DEBUG
=
0
;
const
LEVEL_INFO
=
1
;
const
LEVEL_WARNING
=
2
;
const
LEVEL_ERROR
=
3
;
const
LEVEL_FATAL
=
4
;
private
array
$log_dict
;
public
function
__construct
(
array
$log_dict
){
$this
->
log_dict
=
$log_dict
;
}
public
function
getTimestamp
():
\
DateTime
{
// "%Y-%m-%dT%H:%M:%S.%fZ"
if
(
array_key_exists
(
'timestamp'
,
$this
->
log_dict
)){
return
new
\
DateTime
(
$this
->
log_dict
[
'timestamp'
]);
}
}
public
function
getMessage
():
string
{
if
(
array_key_exists
(
'message'
,
$this
->
log_dict
)){
return
$this
->
log_dict
[
'message'
];
}
}
public
function
getLevel
():
int
{
if
(
array_key_exists
(
'level'
,
$this
->
log_dict
)){
switch
(
$this
->
log_dict
[
'level'
]){
case
'DEBUG'
:
return
self
::
LEVEL_DEBUG
;
case
'WARNING'
:
return
self
::
LEVEL_WARNING
;
case
'ERROR'
:
return
self
::
LEVEL_ERROR
;
case
'FATAL'
:
case
'CRITICAL'
:
return
self
::
LEVEL_FATAL
;
default
:
return
self
::
LEVEL_INFO
;
}
}
return
self
::
LEVEL_INFO
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment