@@ -212,6 +212,7 @@ pub(crate) struct Builder {
212212 pub ( crate ) format_suffix : & ' static str ,
213213 pub ( crate ) format_file : bool ,
214214 pub ( crate ) format_line_number : bool ,
215+ pub ( crate ) format_syslog : bool ,
215216 #[ cfg( feature = "unstable-kv" ) ]
216217 pub ( crate ) kv_format : Option < Box < KvFormatFn > > ,
217218 built : bool ,
@@ -237,24 +238,42 @@ impl Builder {
237238 if let Some ( fmt) = built. custom_format {
238239 fmt
239240 } else {
240- Box :: new ( move |buf, record| {
241- let fmt = DefaultFormat {
242- timestamp : built. format_timestamp ,
243- module_path : built. format_module_path ,
244- target : built. format_target ,
245- level : built. format_level ,
246- written_header_value : false ,
247- indent : built. format_indent ,
248- suffix : built. format_suffix ,
249- source_file : built. format_file ,
250- source_line_number : built. format_line_number ,
251- #[ cfg( feature = "unstable-kv" ) ]
252- kv_format : built. kv_format . as_deref ( ) . unwrap_or ( & default_kv_format) ,
253- buf,
254- } ;
255-
256- fmt. write ( record)
257- } )
241+ if !built. format_syslog {
242+ Box :: new ( move |buf, record| {
243+ let fmt = DefaultFormat {
244+ timestamp : built. format_timestamp ,
245+ module_path : built. format_module_path ,
246+ target : built. format_target ,
247+ level : built. format_level ,
248+ written_header_value : false ,
249+ indent : built. format_indent ,
250+ suffix : built. format_suffix ,
251+ source_file : built. format_file ,
252+ source_line_number : built. format_line_number ,
253+ #[ cfg( feature = "unstable-kv" ) ]
254+ kv_format : built. kv_format . as_deref ( ) . unwrap_or ( & default_kv_format) ,
255+ buf,
256+ } ;
257+
258+ fmt. write ( record)
259+ } )
260+ } else {
261+ Box :: new ( |buf, record| {
262+ writeln ! (
263+ buf,
264+ "<{}>{}: {}" ,
265+ match record. level( ) {
266+ Level :: Error => 3 ,
267+ Level :: Warn => 4 ,
268+ Level :: Info => 6 ,
269+ Level :: Debug => 7 ,
270+ Level :: Trace => 7 ,
271+ } ,
272+ record. target( ) ,
273+ record. args( )
274+ )
275+ } )
276+ }
258277 }
259278 }
260279}
@@ -271,6 +290,7 @@ impl Default for Builder {
271290 format_indent : Some ( 4 ) ,
272291 custom_format : None ,
273292 format_suffix : "\n " ,
293+ format_syslog : false ,
274294 #[ cfg( feature = "unstable-kv" ) ]
275295 kv_format : None ,
276296 built : false ,
0 commit comments