Skip to content

Commit a00c728

Browse files
datameloliver-sanders
authored andcommitted
log: support other workflow log files and timestamp redaction
* Support viewing other workflow log files e.g. `config/` and `install/`. * Support stripping timestamps from logs.
1 parent 8bfbfac commit a00c728

File tree

9 files changed

+2266
-2553
lines changed

9 files changed

+2266
-2553
lines changed

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"version": "1.5.0",
44
"private": true,
55
"license": "GPL-3.0-only",
6-
76
"scripts": {
87
"build": "vue-cli-service build",
98
"build:report": "vue-cli-service build --report",
@@ -21,7 +20,6 @@
2120
"test:unit": "vue-cli-service test:unit",
2221
"test": "yarn run test:unit || exit 1; yarn run coverage:e2e --headless"
2322
},
24-
2523
"dependencies": {
2624
"@apollo/client": "^3.5.8",
2725
"@hpcc-js/wasm": "1.13",
@@ -50,7 +48,6 @@
5048
"vuetify": "^2.6.10",
5149
"vuex": "^3.6.2"
5250
},
53-
5451
"devDependencies": {
5552
"@babel/core": "^7.14.8",
5653
"@babel/eslint-parser": "^7.16.5",

src/components/cylc/cylcObject/Menu.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,9 @@ export default {
264264
},
265265
openDialog (mutation) {
266266
if (mutation.name === 'log') {
267-
this.showMenu = false
268267
this.$eventBus.emit(
269268
'add-view',
270269
{
271-
272270
viewName: 'Log',
273271
initialOptions: {
274272
workflow: this.node.tokens.workflow,
@@ -277,6 +275,7 @@ export default {
277275
}
278276
}
279277
)
278+
this.showMenu = false
280279
return
281280
}
282281

src/components/cylc/log/Log.vue

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
<template>
1919
<div>
20-
<pre><span v-for="(log, index) in logs" :key="index">{{log}}</span></pre>
20+
<pre><code><span v-for="(log, index) in computedLogs" :key="index">{{log}}</span></code></pre>
2121
</div>
2222
</template>
2323

@@ -31,20 +31,52 @@ export default {
3131
default: 'Waiting for logs',
3232
required: false
3333
},
34+
timestamps: {
35+
type: Boolean,
36+
required: false,
37+
default: true
38+
},
3439
logs: {
3540
type: Array,
3641
required: true
3742
}
3843
},
44+
data () {
45+
return {
46+
match: ''
47+
}
48+
},
3949
computed: {
4050
computedLogs () {
4151
if (this.logs.length > 0) {
42-
return this.logs
52+
if (!this.timestamps) {
53+
return this.updateLogs()
54+
} else return this.logs
4355
} else {
4456
return [this.placeholder]
4557
}
4658
}
59+
},
60+
methods: {
61+
updateLogs () {
62+
return this.logs.map((logLine) => {
63+
return this.stripTimestamp(logLine)
64+
})
65+
},
66+
stripTimestamp (logLine) {
67+
const regex = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-][\d:]+)?\s(.*\s*)/
68+
this.match = logLine.match(regex)
69+
if (this.match) {
70+
return this.match[1]
71+
}
72+
return logLine
73+
}
4774
}
4875
}
4976
5077
</script>
78+
<style>
79+
.theme--light.v-application code{
80+
background-color: transparent;
81+
}
82+
</style>

src/graphql/queries.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,26 @@ ${WORKFLOW_DATA_FRAGMENT}
202202
* @type {DocumentNode}
203203
*/
204204
const LOGS_SUBSCRIPTION = gql`
205-
subscription LogData ($workflowName: ID, $task: String, $file: String) {
205+
subscription LogData ($workflowName: ID, $task: String!, $file: String!) {
206206
logs (workflow: $workflowName, task:$task, file: $file) {
207207
lines
208208
}
209209
}
210210
`
211211

212+
/**
213+
* Query used to retrieve available log files for the Log view.
214+
*
215+
* @type {DocumentNode}
216+
*/
217+
const LOG_FILE_QUERY = gql`
218+
query LogFiles($workflowName: ID, $task: String!) {
219+
logFiles(workflow: $workflowName, task: $task) {
220+
files
221+
}
222+
}
223+
`
224+
212225
/**
213226
* Query used to retrieve data for the WorkflowsTable view.
214227
*
@@ -391,6 +404,7 @@ ${JOB_DATA_FRAGMENT}
391404
`
392405

393406
export {
407+
LOG_FILE_QUERY,
394408
GSCAN_DELTAS_SUBSCRIPTION,
395409
DASHBOARD_DELTAS_SUBSCRIPTION,
396410
LOGS_SUBSCRIPTION,

src/router/paths.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,16 @@ export default [
123123
showSidebar: false
124124
},
125125
props: true
126+
},
127+
{
128+
path: '/log/:workflowName(.*)',
129+
view: 'Log',
130+
name: 'log',
131+
meta: {
132+
layout: 'default',
133+
toolbar: true,
134+
showSidebar: false
135+
},
136+
props: true
126137
}
127138
]

src/services/workflow.service.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ class WorkflowService {
127127
* @param {string} queryName
128128
* @param {Object} args
129129
* @param {Field[]} fields
130-
* @param {Object} variables
131130
* @return {Promise<Object>}
132131
* @memberof WorkflowService
133132
*/

src/utils/aotf.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ export const dummyMutations = [
308308
args: [],
309309
_appliesTo: cylcObjects.Namespace,
310310
_requiresInfo: true
311+
},
312+
{
313+
name: 'log',
314+
description: 'View the logs.',
315+
args: [],
316+
_appliesTo: cylcObjects.Job,
317+
_requiresInfo: true
311318
}
312319
]
313320

0 commit comments

Comments
 (0)