@@ -12,6 +12,7 @@ import type { OnLogFn } from "../../connection";
1212import { useLogStore , useRunStore } from "../../store" ;
1313import { logSelectors , runSelectors } from "../../store/selectors" ;
1414import {
15+ clearLogOnExecutionStart ,
1516 showLogOnExecutionFinish ,
1617 showLogOnExecutionStart ,
1718} from "../utils/settings" ;
@@ -20,6 +21,7 @@ const { setProducedExecutionLogOutput } = useLogStore.getState();
2021
2122let outputChannel : OutputChannel ;
2223let data : string [ ] = [ ] ;
24+ let fileName = "" ;
2325
2426export const legend = {
2527 tokenTypes : [ "error" , "warning" , "note" ] ,
@@ -66,9 +68,16 @@ export const appendLogToken = (type: string): void => {
6668 data . push ( type ) ;
6769} ;
6870
71+ export const setFileName = ( name : string ) => {
72+ fileName = name ;
73+ } ;
74+
6975const appendLogLines : OnLogFn = ( logs ) => {
7076 if ( ! outputChannel ) {
71- outputChannel = window . createOutputChannel ( l10n . t ( "SAS Log" ) , "sas-log" ) ;
77+ const name = clearLogOnExecutionStart ( )
78+ ? l10n . t ( "SAS Log: {name}" , { name : fileName } )
79+ : l10n . t ( "SAS Log" ) ;
80+ outputChannel = window . createOutputChannel ( name , "sas-log" ) ;
7281 }
7382 for ( const line of logs ) {
7483 appendLogToken ( line . type ) ;
@@ -100,6 +109,12 @@ useRunStore.subscribe(
100109 }
101110 } else if ( isExecuting && ! prevIsExecuting ) {
102111 setProducedExecutionLogOutput ( false ) ;
112+
113+ if ( clearLogOnExecutionStart ( ) && outputChannel ) {
114+ outputChannel . dispose ( ) ;
115+ outputChannel = undefined ;
116+ data = [ ] ;
117+ }
103118 }
104119 } ,
105120) ;
0 commit comments