@@ -18,6 +18,14 @@ export type SignalDaemonHandle = {
1818 stop : ( ) => void ;
1919} ;
2020
21+ export function classifySignalCliLogLine ( line : string ) : "log" | "error" | null {
22+ const trimmed = line . trim ( ) ;
23+ if ( ! trimmed ) return null ;
24+ // signal-cli commonly writes all logs to stderr; treat severity explicitly.
25+ if ( / \b ( E R R O R | W A R N | W A R N I N G ) \b / . test ( trimmed ) ) return "error" ;
26+ return "log" ;
27+ }
28+
2129function buildDaemonArgs ( opts : SignalDaemonOpts ) : string [ ] {
2230 const args : string [ ] = [ ] ;
2331 if ( opts . account ) {
@@ -46,12 +54,18 @@ export function spawnSignalDaemon(opts: SignalDaemonOpts): SignalDaemonHandle {
4654 const error = opts . runtime ?. error ?? ( ( ) => { } ) ;
4755
4856 child . stdout ?. on ( "data" , ( data ) => {
49- const text = data . toString ( ) . trim ( ) ;
50- if ( text ) log ( `signal-cli: ${ text } ` ) ;
57+ for ( const line of data . toString ( ) . split ( / \r ? \n / ) ) {
58+ const kind = classifySignalCliLogLine ( line ) ;
59+ if ( kind === "log" ) log ( `signal-cli: ${ line . trim ( ) } ` ) ;
60+ else if ( kind === "error" ) error ( `signal-cli: ${ line . trim ( ) } ` ) ;
61+ }
5162 } ) ;
5263 child . stderr ?. on ( "data" , ( data ) => {
53- const text = data . toString ( ) . trim ( ) ;
54- if ( text ) error ( `signal-cli: ${ text } ` ) ;
64+ for ( const line of data . toString ( ) . split ( / \r ? \n / ) ) {
65+ const kind = classifySignalCliLogLine ( line ) ;
66+ if ( kind === "log" ) log ( `signal-cli: ${ line . trim ( ) } ` ) ;
67+ else if ( kind === "error" ) error ( `signal-cli: ${ line . trim ( ) } ` ) ;
68+ }
5569 } ) ;
5670 child . on ( "error" , ( err ) => {
5771 error ( `signal-cli spawn error: ${ String ( err ) } ` ) ;
0 commit comments