@@ -431,9 +431,9 @@ pub fn weekly(
431431/// let appender = tracing_appender::rolling::size("/some/path", "rolling.log");
432432/// let (non_blocking_appender, _guard) = tracing_appender::non_blocking(appender);
433433///
434- /// let collector = tracing_subscriber::fmt().with_writer(non_blocking_appender);
434+ /// let subscriber = tracing_subscriber::fmt().with_writer(non_blocking_appender);
435435///
436- /// tracing::collect ::with_default(collector .finish(), || {
436+ /// tracing::subscriber ::with_default(subscriber .finish(), || {
437437/// tracing::event!(tracing::Level::INFO, "Hello");
438438/// });
439439/// # }
@@ -599,7 +599,9 @@ impl Rotation {
599599 }
600600 // Rotation::SIZE is impossible to round.
601601 Rotation :: SIZE => {
602- unreachable ! ( "Rotation::SIZE is impossible to round." )
602+ let time = Time :: from_hms ( date. hour ( ) , date. minute ( ) , date. second ( ) )
603+ . expect ( "Invalid time; this is a bug in tracing-appender" ) ;
604+ date. replace_time ( time)
603605 }
604606 // Rotation::NEVER is impossible to round.
605607 Rotation :: NEVER => {
@@ -614,9 +616,9 @@ impl Rotation {
614616 Rotation :: HOURLY => format_description:: parse ( "[year]-[month]-[day]-[hour]" ) ,
615617 Rotation :: DAILY => format_description:: parse ( "[year]-[month]-[day]" ) ,
616618 Rotation :: WEEKLY => format_description:: parse ( "[year]-[month]-[day]" ) ,
617- Rotation :: SIZE => format_description :: parse (
618- "[year]-[month]-[day]-[hour]-[minute]-[second]-[subsecond]" ,
619- ) ,
619+ Rotation :: SIZE => {
620+ format_description :: parse ( "[year]-[month]-[day]-[hour]-[minute]-[second]" )
621+ }
620622 Rotation :: NEVER => format_description:: parse ( "[year]-[month]-[day]" ) ,
621623 }
622624 . expect ( "Unable to create a formatter; this is a bug in tracing-appender" )
@@ -1111,7 +1113,7 @@ mod test {
11111113 suffix: None ,
11121114 } ,
11131115 TestCase {
1114- expected: "app.log.2020-02-01-10-01-00-0 " ,
1116+ expected: "app.log.2020-02-01-10-01-00" ,
11151117 rotation: Rotation :: SIZE ,
11161118 prefix: Some ( "app.log" ) ,
11171119 suffix: None ,
@@ -1142,7 +1144,7 @@ mod test {
11421144 suffix: Some ( "log" ) ,
11431145 } ,
11441146 TestCase {
1145- expected: "app.2020-02-01-10-01-00-0 .log" ,
1147+ expected: "app.2020-02-01-10-01-00.log" ,
11461148 rotation: Rotation :: SIZE ,
11471149 prefix: Some ( "app" ) ,
11481150 suffix: Some ( "log" ) ,
@@ -1173,7 +1175,7 @@ mod test {
11731175 suffix: Some ( "log" ) ,
11741176 } ,
11751177 TestCase {
1176- expected: "2020-02-01-10-01-00-0 .log" ,
1178+ expected: "2020-02-01-10-01-00.log" ,
11771179 rotation: Rotation :: SIZE ,
11781180 prefix: None ,
11791181 suffix: Some ( "log" ) ,
@@ -1389,7 +1391,7 @@ mod test {
13891391 )
13901392 . unwrap ( ) ;
13911393
1392- const MAX_FILE_SIZE : u64 = 1024 ;
1394+ const MAX_FILE_SIZE : u64 = 2048 ;
13931395 let now = OffsetDateTime :: parse ( "2020-02-01 10:01:00 +00:00:00" , & format) . unwrap ( ) ;
13941396 let directory = tempfile:: tempdir ( ) . expect ( "failed to create tempdir" ) ;
13951397 let ( state, writer) = Inner :: new (
@@ -1419,9 +1421,9 @@ mod test {
14191421 . set_default ( ) ;
14201422
14211423 for file_num in 0 ..5 {
1422- for i in 0 ..58 {
1424+ for i in 0 ..200 {
14231425 tracing:: info!( "file {} content {}" , file_num, i) ;
1424- ( * clock. lock ( ) . unwrap ( ) ) += Duration :: milliseconds ( 1 ) ;
1426+ ( * clock. lock ( ) . unwrap ( ) ) += Duration :: milliseconds ( 100 ) ;
14251427 }
14261428 }
14271429
@@ -1443,9 +1445,8 @@ mod test {
14431445 let file = fs:: read_to_string ( & path) . expect ( "Failed to read file" ) ;
14441446 println ! ( "path={}\n file={:?}" , path. display( ) , file) ;
14451447
1446- assert_eq ! (
1447- MAX_FILE_SIZE + 10 ,
1448- file_metadata. len( ) ,
1448+ assert ! (
1449+ file_metadata. len( ) <= MAX_FILE_SIZE + 16 ,
14491450 "expected size = {:?}, file size = {:?}" ,
14501451 MAX_FILE_SIZE ,
14511452 file_metadata. len( ) ,
0 commit comments