@@ -33,13 +33,13 @@ import {
3333 FRESH_FLAG ,
3434 TARGET_PATTERN_NOTE ,
3535} from "../../lib/list-command.js" ;
36+ import { logger } from "../../lib/logger.js" ;
3637import {
3738 resolveOrg ,
3839 resolveOrgProjectFromArg ,
3940} from "../../lib/resolve-target.js" ;
4041import { validateTraceId } from "../../lib/trace-id.js" ;
4142import { getUpdateNotification } from "../../lib/version-check.js" ;
42- import type { Writer } from "../../types/index.js" ;
4343
4444type ListFlags = {
4545 readonly limit : number ;
@@ -227,13 +227,13 @@ function abortableSleep(ms: number, signal: AbortSignal): Promise<void> {
227227 *
228228 * Unlike the old callback-based approach, this does NOT include
229229 * stdout/stderr. All stdout output flows through yielded chunks;
230- * stderr diagnostics use the `onDiagnostic` callback.
230+ * diagnostics are reported via the `onDiagnostic` callback.
231231 */
232232type FollowGeneratorConfig < T extends LogLike > = {
233233 flags : ListFlags ;
234234 /** Whether to show the trace-ID column in table output */
235235 includeTrace : boolean ;
236- /** Report diagnostic/error messages (caller writes to stderr ) */
236+ /** Report diagnostic/error messages (caller logs via logger ) */
237237 onDiagnostic : ( message : string ) => void ;
238238 /**
239239 * Fetch logs with the given time window.
@@ -321,8 +321,8 @@ async function fetchPoll<T extends LogLike>(
321321 * - `data` chunks contain raw log arrays for JSONL serialization
322322 *
323323 * The generator handles SIGINT via AbortController for clean shutdown.
324- * It never touches stdout/stderr directly — all output flows through
325- * yielded chunks and the `onDiagnostic` callback.
324+ * It never touches stdout directly — all data output flows through
325+ * yielded chunks and diagnostics use the `onDiagnostic` callback.
326326 *
327327 * @throws {AuthError } if the API returns an authentication error
328328 */
@@ -455,25 +455,20 @@ async function executeTraceSingleFetch(
455455}
456456
457457/**
458- * Write the follow-mode banner to stderr . Suppressed in JSON mode.
458+ * Write the follow-mode banner via logger . Suppressed in JSON mode.
459459 * Includes poll interval, Ctrl+C hint, and update notification.
460460 */
461- function writeFollowBanner (
462- stderr : Writer ,
463- flags : ListFlags ,
464- bannerText : string
465- ) : void {
461+ function writeFollowBanner ( flags : ListFlags , bannerText : string ) : void {
466462 if ( flags . json ) {
467463 return ;
468464 }
469465 const pollInterval = flags . follow ?? DEFAULT_POLL_INTERVAL ;
470- stderr . write ( `${ bannerText } (poll interval: ${ pollInterval } s)\n ` ) ;
471- stderr . write ( "Press Ctrl+C to stop.\n " ) ;
466+ logger . info ( `${ bannerText } (poll interval: ${ pollInterval } s)` ) ;
467+ logger . info ( "Press Ctrl+C to stop." ) ;
472468 const notification = getUpdateNotification ( ) ;
473469 if ( notification ) {
474- stderr . write ( notification ) ;
470+ logger . info ( notification ) ;
475471 }
476- stderr . write ( "\n" ) ;
477472}
478473
479474// ---------------------------------------------------------------------------
@@ -631,23 +626,18 @@ export const listCommand = buildListCommand("log", {
631626 setContext ( [ org ] , [ ] ) ;
632627
633628 if ( flags . follow ) {
634- const { stderr } = this ;
635629 const traceId = flags . trace ;
636630
637- // Banner (stderr, suppressed in JSON mode)
638- writeFollowBanner (
639- stderr ,
640- flags ,
641- `Streaming logs for trace ${ traceId } ...`
642- ) ;
631+ // Banner (suppressed in JSON mode)
632+ writeFollowBanner ( flags , `Streaming logs for trace ${ traceId } ...` ) ;
643633
644634 // Track IDs of logs seen without timestamp_precise so they are
645635 // shown once but not duplicated on subsequent polls.
646636 const seenWithoutTs = new Set < string > ( ) ;
647637 const generator = generateFollowLogs ( {
648638 flags,
649639 includeTrace : false ,
650- onDiagnostic : ( msg ) => stderr . write ( msg ) ,
640+ onDiagnostic : ( msg ) => logger . warn ( msg ) ,
651641 fetch : ( statsPeriod ) =>
652642 listTraceLogs ( org , traceId , {
653643 query : flags . query ,
@@ -704,14 +694,12 @@ export const listCommand = buildListCommand("log", {
704694 setContext ( [ org ] , [ project ] ) ;
705695
706696 if ( flags . follow ) {
707- const { stderr } = this ;
708-
709- writeFollowBanner ( stderr , flags , "Streaming logs..." ) ;
697+ writeFollowBanner ( flags , "Streaming logs..." ) ;
710698
711699 const generator = generateFollowLogs ( {
712700 flags,
713701 includeTrace : true ,
714- onDiagnostic : ( msg ) => stderr . write ( msg ) ,
702+ onDiagnostic : ( msg ) => logger . warn ( msg ) ,
715703 fetch : ( statsPeriod , afterTimestamp ) =>
716704 listLogs ( org , project , {
717705 query : flags . query ,
0 commit comments