File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
crates/openshell-sandbox/src Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -95,15 +95,18 @@ struct Args {
9595async fn main ( ) -> Result < ( ) > {
9696 let args = Args :: parse ( ) ;
9797
98- // Try to open the log file; fall back to stdout-only logging if it fails
98+ // Try to open a rolling log file; fall back to stdout-only logging if it fails
9999 // (e.g., /var/log is not writable in custom workload images).
100- let file_logging = std:: fs:: OpenOptions :: new ( )
101- . create ( true )
102- . append ( true )
103- . open ( "/var/log/openshell.log" )
100+ // Rotates daily, keeps the 3 most recent files to bound disk usage.
101+ let file_logging = tracing_appender:: rolling:: RollingFileAppender :: builder ( )
102+ . rotation ( tracing_appender:: rolling:: Rotation :: DAILY )
103+ . filename_prefix ( "openshell" )
104+ . filename_suffix ( "log" )
105+ . max_log_files ( 3 )
106+ . build ( "/var/log" )
104107 . ok ( )
105- . map ( |file | {
106- let ( writer, guard) = tracing_appender:: non_blocking ( file ) ;
108+ . map ( |roller | {
109+ let ( writer, guard) = tracing_appender:: non_blocking ( roller ) ;
107110 ( writer, guard)
108111 } ) ;
109112
@@ -156,7 +159,7 @@ async fn main() -> Result<()> {
156159 . with ( push_layer)
157160 . init ( ) ;
158161 // Log the warning after the subscriber is initialized
159- warn ! ( "Could not open /var/log/openshell. log; using stdout-only logging" ) ;
162+ warn ! ( "Could not open /var/log for log rotation ; using stdout-only logging" ) ;
160163 None
161164 } ;
162165
You can’t perform that action at this time.
0 commit comments