Skip to content

Commit

Permalink
feat(console): add debug prefix (#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaggioni authored Aug 17, 2024
1 parent 78d563e commit e0f5f78
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/console/ConsoleTableEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class ConsoleTableEntry extends Mixins(BaseMixin) {
get entryStyle() {
const classes = ['ma-0', 'flex-nowrap']
classes.push(this.$store.state.gui.console.entryStyle ?? 'default')
if (this.event.type === 'action') classes.push('text--disabled')
if (['action', 'debug'].includes(this.event.type)) classes.push('text--disabled')
return classes
}
Expand All @@ -31,7 +31,7 @@ export default class ConsoleTableEntry extends Mixins(BaseMixin) {
get messageClass() {
const classes = ['console-message']
if (this.event.type === 'action') classes.push('text--disabled')
if (['action', 'debug'].includes(this.event.type)) classes.push('text--disabled')
else if (this.event.message.startsWith('!! ')) classes.push('error--text')
else classes.push('text--primary')
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export function formatConsoleMessage(message: string): string {
message = message.replace(/\n\/\/ /g, '\n')
// remove echo
message = message.replace(/^echo:/g, '')
// remove debug
message = message.replace(/^debug:/g, '')
// replace linebreaks with html <br>
message = message.replace('\n// ', '<br>')
message = message.replace(/\r\n|\r|\n/g, '<br>')
Expand Down
5 changes: 4 additions & 1 deletion src/store/server/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ export const actions: ActionTree<ServerState, RootState> = {
else if ('error' in payload) message = message.error.message

let formatMessage = formatConsoleMessage(message)
if (type === 'response' && message.startsWith('// action:')) type = 'action'
if (type === 'response') {
if (message.startsWith('// action:')) type = 'action'
else if (message.startsWith('// debug:')) type = 'debug'
}

const filters = rootGetters['gui/console/getConsolefilterRules']
let boolImport = true
Expand Down
5 changes: 4 additions & 1 deletion src/store/server/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ export const mutations: MutationTree<ServerState> = {

let type = message.type
if (type === 'command') formatMessage = '<a class="command text--blue">' + formatMessage + '</a>'
if (type === 'response' && message.message.startsWith('// action:')) type = 'action'
if (type === 'response') {
if (message.message.startsWith('// action:')) type = 'action'
else if (message.message.startsWith('// debug:')) type = 'debug'
}

state.events.push({
date,
Expand Down

0 comments on commit e0f5f78

Please sign in to comment.