Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cronlog-viewer
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
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
IML Open Source
Cronlog-viewer
Commits
2a68fee7
Commit
2a68fee7
authored
6 months ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
rename methods for history data
parent
e1d3aa51
No related branches found
Branches containing commit
No related tags found
1 merge request
!18
OP#7365 PHP-8.1 - Upgrade - cronlog Viewer (monitors.ascii)https://projects.iml.unibe.ch/work_packages/7365
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/cronlog-renderer.class.php
+6
-5
6 additions, 5 deletions
classes/cronlog-renderer.class.php
classes/cronlog.class.php
+50
-8
50 additions, 8 deletions
classes/cronlog.class.php
get.php
+3
-3
3 additions, 3 deletions
get.php
with
59 additions
and
16 deletions
classes/cronlog-renderer.class.php
+
6
−
5
View file @
2a68fee7
...
...
@@ -33,7 +33,7 @@ require_once 'cronlog.class.php';
* @license GNU GPL 3.0
* @author Axel Hahn <axel.hahn@iml.unibe.ch>
*
* 2024-
09-20
<axel.hahn@unibe.ch> added type declarations; update php docs
* 2024-
10-01
<axel.hahn@unibe.ch> added type declarations; update php docs
*/
class
cronlogrenderer
extends
cronlog
{
...
...
@@ -342,7 +342,7 @@ class cronlogrenderer extends cronlog
return
''
;
}
$sReturn
=
''
;
$sServer
=
isset
(
$_SERVER
[
'SERVER_NAME'
])
?
$_SERVER
[
'SERVER_NAME'
]
:
false
;
$sServer
=
isset
(
$_SERVER
[
'SERVER_NAME'
])
?
?
false
;
$sReturn
.
=
'<li class="nav-item"><a class="nav-link nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a></li>'
.
'<li class="nav-item d-none d-sm-inline-block"><a href="#" class="nav-link">'
.
$this
->
t
(
'instances'
)
.
':</a></li>'
;
...
...
@@ -360,7 +360,7 @@ class cronlogrenderer extends cronlog
* @param array $aData result of $oCL->getServerLogs()
* @return string
*/
public
function
render
Joblist
(
array
$aData
=
[]):
string
public
function
render
HistoryTable
(
array
$aData
=
[]):
string
{
$sTaskId
=
__FUNCTION__
.
'-'
.
$this
->
_sActiveServer
;
$sHtml
=
$this
->
_getCacheData
(
$sTaskId
);
...
...
@@ -381,6 +381,7 @@ class cronlogrenderer extends cronlog
krsort
(
$aTmp
);
$aData
=
array_values
(
$aTmp
);
// render table
$sTblHead
=
''
;
$iOK
=
0
;
$iErrors
=
0
;
...
...
@@ -482,7 +483,7 @@ class cronlogrenderer extends cronlog
*
* @return string
*/
public
function
render
Joblist
OfAllServers
():
string
public
function
render
History
OfAllServers
():
string
{
$aData
=
[];
foreach
(
array_keys
(
$this
->
getServers
())
as
$sServer
)
{
...
...
@@ -490,7 +491,7 @@ class cronlogrenderer extends cronlog
$aData
=
array_merge
(
$aData
,
$this
->
getServerJobHistory
());
}
$this
->
setServer
(
'ALL'
);
return
$this
->
render
Joblist
(
$aData
);
return
$this
->
render
HistoryTable
(
$aData
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
classes/cronlog.class.php
+
50
−
8
View file @
2a68fee7
...
...
@@ -32,7 +32,7 @@
* @license GNU GPL 3.0
* @author Axel Hahn <axel.hahn@iml.unibe.ch>
*
* 2024-
09-20
<axel.hahn@unibe.ch> added type declarations; update php docs
* 2024-
10-01
<axel.hahn@unibe.ch> added type declarations; update php docs
*/
class
cronlog
...
...
@@ -46,7 +46,7 @@ class cronlog
protected
string
$_sDataDir
=
"__APPDIR__/data"
;
/**
* TTL for cached
data
* TTL for cached
rendered html output of logs/ history/ timeline
* @var int
*/
protected
int
$_iTtlCache
=
60
;
// in sec
...
...
@@ -69,16 +69,52 @@ class cronlog
*/
protected
array
$_aSkipJoblogs
=
[];
/**
* Array of cronlog viewer instances to show a navigation to switch between them
* @var array
*/
protected
array
$_aInstances
=
[];
/**
* Array of all servers with cronjobs
* @var array
*/
protected
array
$_aServers
=
[];
/**
* Current server
* @var string
*/
protected
string
$_sActiveServer
=
''
;
/**
* Filefilter for finished joblogs
* @var string
*/
protected
string
$_sFileFilter_serverjoblog
=
'*joblog*.done'
;
/**
* Filefilter for history logs
* @var string
*/
protected
string
$_sFileFilter_joblog
=
'*.log'
;
/**
* Filefilter for running jobs
* @var string
*/
protected
string
$_sFileFilter_jobrunning
=
'*.log.running*'
;
/**
* Current language
* @var string
*/
protected
string
$_sLang
=
''
;
// language ... read from config file
/**
* Array of language texts
* @var array
*/
protected
array
$_aLang
=
[];
// language data
// ----------------------------------------------------------------------
...
...
@@ -125,7 +161,10 @@ class cronlog
*/
protected
function
_getCacheDir
():
string
{
return
$this
->
_sDataDir
.
'/__cache'
;
if
(
!
is_dir
(
"
$this->_sDataDir
/__cache"
))
{
mkdir
(
"
$this->_sDataDir
/__cache"
,
0750
,
true
);
}
return
"
$this->_sDataDir
/__cache"
;
}
/**
...
...
@@ -135,7 +174,7 @@ class cronlog
*/
protected
function
_getCacheFile
(
string
$sTaskId
):
string
{
return
$this
->
_getCacheDir
()
.
'/'
.
$sTaskId
;
return
$this
->
_getCacheDir
()
.
"/
$sTaskId
"
;
}
/**
...
...
@@ -144,17 +183,20 @@ class cronlog
*/
protected
function
_getServerlogDir
():
string
{
return
$this
->
_sDataDir
.
'/'
.
$this
->
_sActiveServer
;
return
"
$this->_sDataDir
/
$this->_sActiveServer
"
;
}
/**
* Caching: get cached data if they exist and aren't expired
* Caching: get cached data for rendered html output
* if they exist and isn't expired
*
* @param string $sTaskId Name of the task
* @return mixed string|array
*/
protected
function
_getCacheData
(
string
$sTaskId
):
string
|
array
{
// DISABLE CACHE return false;
// DISABLE CACHE
// return false;
$sFile
=
$this
->
_getCacheFile
(
$sTaskId
);
if
(
file_exists
(
$sFile
))
{
if
(
filemtime
(
$sFile
)
>
(
date
(
'U'
)
-
$this
->
_iTtlCache
))
{
...
...
@@ -288,7 +330,7 @@ class cronlog
}
/**
* Get logs from jobfile
a
of the current or given server
* Get logs from jobfile
s
of the current or given server
* @param boolean $bUseSkip hide jobs if their label matches the skip list; default: true
* @return array
*/
...
...
This diff is collapsed.
Click to expand it.
get.php
+
3
−
3
View file @
2a68fee7
...
...
@@ -48,9 +48,9 @@ if($sServer){
switch
(
$sItem
){
case
'cronhistory'
:
if
(
$sServer
===
'ALL'
){
$sHtml
.
=
$oCL
->
render
Joblist
OfAllServers
();
$sHtml
.
=
$oCL
->
render
History
OfAllServers
();
}
else
{
$sHtml
.
=
$oCL
->
render
Joblist
();
$sHtml
.
=
$oCL
->
render
HistoryTable
();
}
break
;
case
'cronlogs'
:
...
...
@@ -68,7 +68,7 @@ switch ($sItem){
}
break
;
case
'instances'
:
$sHtml
.
=
$oCL
->
renderInstances
(
$sServer
);
$sHtml
.
=
$oCL
->
renderInstances
();
break
;
case
'selectserver'
:
$sHtml
.
=
$oCL
->
renderServerlist
(
$sServer
);
...
...
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