@@ -49,7 +49,7 @@ type ListFlags = {
4949 readonly limit : number ;
5050 readonly query ?: string ;
5151 readonly follow ?: number ;
52- readonly period : string ;
52+ readonly period ? : string ;
5353 readonly json : boolean ;
5454 readonly fresh : boolean ;
5555 readonly fields ?: string [ ] ;
@@ -198,15 +198,19 @@ function parseLogListArgs(args: string[]): ParsedLogArgs {
198198 * Returns the logs and a hint. The caller yields the result and
199199 * returns the hint as a footer via `CommandReturn`.
200200 */
201+ /** Default time period for project-scoped log queries */
202+ const DEFAULT_PROJECT_PERIOD = "90d" ;
203+
201204async function executeSingleFetch (
202205 org : string ,
203206 project : string ,
204207 flags : ListFlags
205208) : Promise < FetchResult > {
209+ const period = flags . period ?? DEFAULT_PROJECT_PERIOD ;
206210 const logs = await listLogs ( org , project , {
207211 query : flags . query ,
208212 limit : flags . limit ,
209- statsPeriod : flags . period ,
213+ statsPeriod : period ,
210214 } ) ;
211215
212216 if ( logs . length === 0 ) {
@@ -459,9 +463,9 @@ async function executeTraceSingleFetch(
459463 traceId : string ,
460464 flags : ListFlags
461465) : Promise < FetchResult > {
462- // In trace mode, use a shorter default period if the user hasn't
463- // explicitly changed it from the command-level default of "90d ".
464- const period = flags . period === "90d" ? DEFAULT_TRACE_PERIOD : flags . period ;
466+ // Use the explicit period if set, otherwise default to 14d for trace mode.
467+ // The flag is optional (no default) so undefined means "not explicitly set ".
468+ const period = flags . period ?? DEFAULT_TRACE_PERIOD ;
465469
466470 const logs = await listTraceLogs ( org , traceId , {
467471 query : flags . query ,
@@ -663,8 +667,9 @@ export const listCommand = buildListCommand("log", {
663667 period : {
664668 kind : "parsed" ,
665669 parse : String ,
666- brief : 'Time period (e.g., "90d", "14d", "24h")' ,
667- default : "90d" ,
670+ brief :
671+ 'Time period (e.g., "90d", "14d", "24h"). Default: 90d (project mode), 14d (trace mode)' ,
672+ optional : true ,
668673 } ,
669674 fresh : FRESH_FLAG ,
670675 } ,
@@ -740,7 +745,7 @@ export const listCommand = buildListCommand("log", {
740745 }
741746
742747 const { result, hint } = await withProgress (
743- { message : "Fetching logs..." } ,
748+ { message : "Fetching logs..." , json : flags . json } ,
744749 ( ) => executeTraceSingleFetch ( org , traceId , flags )
745750 ) ;
746751 yield new CommandOutput ( result ) ;
@@ -781,7 +786,7 @@ export const listCommand = buildListCommand("log", {
781786 }
782787
783788 const { result, hint } = await withProgress (
784- { message : "Fetching logs..." } ,
789+ { message : "Fetching logs..." , json : flags . json } ,
785790 ( ) => executeSingleFetch ( org , project , flags )
786791 ) ;
787792 yield new CommandOutput ( result ) ;
0 commit comments