@@ -20,6 +20,11 @@ fn validate_max_rows(s: &str) -> Result<usize> {
2020 }
2121}
2222
23+ /// Check if a project identifier is numeric (project ID) or string (project slug)
24+ fn is_numeric_project_id ( project : & str ) -> bool {
25+ project. chars ( ) . all ( |c| c. is_ascii_digit ( ) )
26+ }
27+
2328/// Fields to fetch from the logs API
2429const LOG_FIELDS : & [ & str ] = & [
2530 "sentry.item_id" ,
@@ -37,7 +42,7 @@ pub(super) struct ListLogsArgs {
3742 org : Option < String > ,
3843
3944 #[ arg( short = 'p' , long = "project" ) ]
40- #[ arg( help = "The project ID (slug not supported )." ) ]
45+ #[ arg( help = "The project ID (numeric) or project slug (string )." ) ]
4146 project : Option < String > ,
4247
4348 #[ arg( long = "max-rows" , default_value = "100" ) ]
@@ -70,29 +75,41 @@ pub(super) fn execute(args: ListLogsArgs) -> Result<()> {
7075
7176 let api = Api :: current ( ) ;
7277
73- let query = if args. query . is_empty ( ) {
74- None
78+ let ( query, project_id) = if is_numeric_project_id ( project) {
79+ // For numeric project IDs, pass as project parameter
80+ let query = if args. query . is_empty ( ) {
81+ String :: new ( )
82+ } else {
83+ args. query . clone ( )
84+ } ;
85+ ( query, Some ( project. as_str ( ) ) )
7586 } else {
76- Some ( args. query . as_str ( ) )
87+ // For project slugs, include in query string
88+ let query = if args. query . is_empty ( ) {
89+ format ! ( "project:{project}" )
90+ } else {
91+ format ! ( "project:{project} {}" , args. query)
92+ } ;
93+ ( query, None )
7794 } ;
7895
79- execute_single_fetch ( & api, org, project , query , LOG_FIELDS , & args)
96+ execute_single_fetch ( & api, org, & query , project_id , LOG_FIELDS , & args)
8097}
8198
8299fn execute_single_fetch (
83100 api : & Api ,
84101 org : & str ,
85- project : & str ,
86- query : Option < & str > ,
102+ query : & str ,
103+ project_id : Option < & str > ,
87104 fields : & [ & str ] ,
88105 args : & ListLogsArgs ,
89106) -> Result < ( ) > {
90107 let options = FetchEventsOptions {
91108 dataset : Dataset :: Logs ,
92109 fields,
93- project_id : project ,
110+ project : project_id ,
94111 cursor : None ,
95- query : query . unwrap_or ( "" ) ,
112+ query,
96113 per_page : args. max_rows ,
97114 stats_period : "90d" ,
98115 sort : "-timestamp" ,
0 commit comments