@@ -211,50 +211,6 @@ impl Builder {
211211 self . parse_env ( Env :: default ( ) )
212212 }
213213
214- /// Sets the format function for formatting the log output,
215- /// and builds the Logger.
216- ///
217- /// This function is called on each record logged and should format the
218- /// log record and output it to the given [`Formatter`].
219- ///
220- /// The format function is expected to output the string directly to the
221- /// `Formatter` so that implementations can use the [`std::fmt`] macros
222- /// to format and output without intermediate heap allocations. The default
223- /// `env_logger` formatter takes advantage of this.
224- ///
225- /// When the `color` feature is enabled, styling via ANSI escape codes is supported and the
226- /// output will automatically respect [`Builder::write_style`].
227- ///
228- /// # Examples
229- ///
230- /// Use a custom format to write only the log message:
231- ///
232- /// ```
233- /// use std::io::Write;
234- /// use env_logger::Builder;
235- ///
236- /// let mut builder = Builder::new();
237- ///
238- /// builder.build_with_format_fn(|buf, record| writeln!(buf, "{}", record.args()));
239- /// ```
240- ///
241- /// [`Formatter`]: fmt/struct.Formatter.html
242- /// [`String`]: https://doc.rust-lang.org/stable/std/string/struct.String.html
243- /// [`std::fmt`]: https://doc.rust-lang.org/std/fmt/index.html
244- pub fn build_with_format_fn < F > ( & mut self , format : F ) -> Logger
245- where
246- F : Fn ( & mut Formatter , & Record < ' _ > ) -> io:: Result < ( ) > + Sync + Send + ' static ,
247- {
248- assert ! ( !self . built, "attempt to re-use consumed builder" ) ;
249- self . built = true ;
250-
251- Logger {
252- writer : self . writer . build ( ) ,
253- filter : self . filter . build ( ) ,
254- format : Box :: new ( format) ,
255- }
256- }
257-
258214 /// Whether or not to write the level in the default format.
259215 pub fn format_level ( & mut self , write : bool ) -> & mut Self {
260216 self . format . level ( write) ;
@@ -527,6 +483,50 @@ impl Builder {
527483 format : Box :: new ( std:: mem:: take ( & mut self . format ) ) ,
528484 }
529485 }
486+
487+ /// Sets the format function for formatting the log output,
488+ /// and builds the Logger.
489+ ///
490+ /// This function is called on each record logged and should format the
491+ /// log record and output it to the given [`Formatter`].
492+ ///
493+ /// The format function is expected to output the string directly to the
494+ /// `Formatter` so that implementations can use the [`std::fmt`] macros
495+ /// to format and output without intermediate heap allocations. The default
496+ /// `env_logger` formatter takes advantage of this.
497+ ///
498+ /// When the `color` feature is enabled, styling via ANSI escape codes is supported and the
499+ /// output will automatically respect [`Builder::write_style`].
500+ ///
501+ /// # Examples
502+ ///
503+ /// Use a custom format to write only the log message:
504+ ///
505+ /// ```
506+ /// use std::io::Write;
507+ /// use env_logger::Builder;
508+ ///
509+ /// let mut builder = Builder::new();
510+ ///
511+ /// builder.build_with_format_fn(|buf, record| writeln!(buf, "{}", record.args()));
512+ /// ```
513+ ///
514+ /// [`Formatter`]: fmt/struct.Formatter.html
515+ /// [`String`]: https://doc.rust-lang.org/stable/std/string/struct.String.html
516+ /// [`std::fmt`]: https://doc.rust-lang.org/std/fmt/index.html
517+ pub fn build_with_format_fn < F > ( & mut self , format : F ) -> Logger
518+ where
519+ F : Fn ( & mut Formatter , & Record < ' _ > ) -> io:: Result < ( ) > + Sync + Send + ' static ,
520+ {
521+ assert ! ( !self . built, "attempt to re-use consumed builder" ) ;
522+ self . built = true ;
523+
524+ Logger {
525+ writer : self . writer . build ( ) ,
526+ filter : self . filter . build ( ) ,
527+ format : Box :: new ( format) ,
528+ }
529+ }
530530}
531531
532532impl std:: fmt:: Debug for Builder {
0 commit comments