1+ import { ConsoleLogger , LogLevel } from '@slack/logger' ;
2+
3+ const logger = new ConsoleLogger ( ) ;
4+ logger . setLevel ( LogLevel . DEBUG ) ;
5+
16/**
27 * Base interface for streaming message chunks.
38 * https://docs.slack.dev/messaging/sending-and-scheduling-messages#text-streaming
@@ -65,7 +70,7 @@ export function parseChunk(chunk: unknown): AnyChunk | null {
6570 const chunkObj = chunk as Record < string , unknown > ;
6671
6772 if ( ! ( 'type' in chunkObj ) || typeof chunkObj . type !== 'string' ) {
68- console . warn ( 'Unknown chunk detected and skipped (missing type)' , chunk ) ;
73+ logger . debug ( 'Unknown chunk detected and skipped (missing type)' , chunk ) ;
6974 return null ;
7075 }
7176
@@ -75,15 +80,15 @@ export function parseChunk(chunk: unknown): AnyChunk | null {
7580 if ( typeof chunkObj . text === 'string' ) {
7681 return chunkObj as unknown as MarkdownTextChunk ;
7782 }
78- console . warn ( 'Invalid MarkdownTextChunk (missing text property)' , chunk ) ;
83+ logger . debug ( 'Invalid MarkdownTextChunk (missing text property)' , chunk ) ;
7984 return null ;
8085 }
8186
82- if ( type === 'plan_update' ) {
87+ if ( type === 'plan_update' ) {
8388 if ( typeof chunkObj . title === 'string' ) {
8489 return chunkObj as unknown as PlanUpdateChunk ;
8590 }
86- console . warn ( 'Invalid PlanUpdateChunk (missing title property)' , chunk ) ;
91+ logger . debug ( 'Invalid PlanUpdateChunk (missing title property)' , chunk ) ;
8792 return null ;
8893 }
8994
@@ -97,10 +102,10 @@ export function parseChunk(chunk: unknown): AnyChunk | null {
97102 ) {
98103 return chunkObj as unknown as TaskUpdateChunk ;
99104 }
100- console . warn ( 'Invalid TaskUpdateChunk (missing required properties)' , chunk ) ;
105+ logger . debug ( 'Invalid TaskUpdateChunk (missing required properties)' , chunk ) ;
101106 return null ;
102107 }
103108
104- console . warn ( `Unknown chunk type detected and skipped: ${ type } ` , chunk ) ;
109+ logger . debug ( `Unknown chunk type detected and skipped: ${ type } ` , chunk ) ;
105110 return null ;
106111}
0 commit comments