pub fn with_open_syslog2<F, R>(programName: &CStr, logToStandardErrorAsWell: bool, defaultFacility: Facility, closure: F) -> R
where F: Fn() -> R
{
	let logMask = default_log_mask();
	
	let mut logOptions = LogOptions::default();
	#[cfg(not(target_os = "solaris"))]
	logOptions.logToStandardErrorAsWell(logToStandardErrorAsWell);
	
	let criticalPriority = defaultFacility.toPriority(Severity::LOG_CRIT);
	
	#[cfg(target_os = "solaris")]
	enable_logging_to_standard_error(programName, logToStandardErrorAsWell, defaultFacility);
	unsafe { openlog(programName.as_ptr(), logOptions.bits() as c_int, defaultFacility as c_int); }
	
	logMask.set_mask();
	
	try_finally(closure, |outcome|
	{
		if let &Err(ref error) = outcome
		{
			let messageResult = match error.downcast_ref::<&str>()
			{
				Some(string) => format!("Panic:{}", string),
				None => format!("Panic:{:?}", error),
			};
			
			match CString::new(messageResult)
			{
				Err(_) => syslog2_bytes(criticalPriority, &UnformattableFatalPanic),
				Ok(ref message) => syslog2_cstr(criticalPriority, message)
			};
		}
		
		unsafe { closelog(); }
	})
}
/// Note, to log to LOG_KERN, you must specify defaultFacility: LOG_KERN, otherwise calls to syslog2(LOG_KERN) will be converted by your underlying C library to syslog2(defaultFacility)
/// This is because LOG_KERN is defined as 0 and the checks in nearly all system c libraries (eg musl) test for the presence of a bit pattern...
/// An easy way to get the progname is to use the process crate's CurrentProcess static field
Note, to log to LOG_KERN, you must specify defaultFacility: LOG_KERN, otherwise calls to syslog2(LOG_KERN) will be converted by your underlying C library to syslog2(defaultFacility)
This is because LOG_KERN is defined as 0 and the checks in nearly all system c libraries  test for the presence of a bit pattern
An easy way to get the progname is to use the process crate's CurrentProcess static field
Note to log to LOG_KERN you must specify defaultFacility : LOG_KERN otherwise calls to syslog2 ( LOG_KERN ) will be converted by your underlying C library to syslog2 ( defaultFacility ) This is because LOG_KERN is defined as 0 and the checks in nearly all system c libraries test for the presence of a bit pattern An easy way to get the progname is to use the process crate ' s CurrentProcess static field
pub fn with_open_syslog2<F, R>(programName: &CStr, logToStandardErrorAsWell: bool, defaultFacility: Facility, closure: F) -> R
where F: Fn() -> R
{
	let logMask = default_log_mask();
	let mut logOptions = LogOptions::default();
	#[cfg(not(target_os = "solaris"))]
	logOptions.logToStandardErrorAsWell(logToStandardErrorAsWell);
	let criticalPriority = defaultFacility.toPriority(Severity::LOG_CRIT);
	#[cfg(target_os = "solaris")]
	enable_logging_to_standard_error(programName, logToStandardErrorAsWell, defaultFacility);
	unsafe { openlog(programName.as_ptr(), logOptions.bits() as c_int, defaultFacility as c_int); }
	logMask.set_mask();
	try_finally(closure, |outcome|
	{
		if let &Err(ref error) = outcome
		{
			let messageResult = match error.downcast_ref::<&str>()
			{
				Some(string) => format!("Panic:{}", string),
				None => format!("Panic:{:?}", error),
			};
			match CString::new(messageResult)
			{
				Err(_) => syslog2_bytes(criticalPriority, &UnformattableFatalPanic),
				Ok(ref message) => syslog2_cstr(criticalPriority, message)
			};
		}
		unsafe { closelog(); }
	})
}
pub fn with_open_syslog2 < F , R > ( programName : & CStr , logToStandardErrorAsWell : bool , defaultFacility : Facility , closure : F ) -> R where F : Fn ( ) -> R { let logMask = default_log_mask ( ) ; let mut logOptions = LogOptions :: default ( ) ; # [ cfg ( not ( target_os " " ) ) ] logOptions . logToStandardErrorAsWell ( logToStandardErrorAsWell ) ; let criticalPriority = defaultFacility . toPriority ( Severity :: LOG_CRIT ) ; # [ cfg ( target_os " " ) ] enable_logging_to_standard_error ( programName , logToStandardErrorAsWell , defaultFacility ) ; unsafe { openlog ( programName . as_ptr ( ) , logOptions . bits ( ) as c_int , defaultFacility as c_int ) ; } logMask . set_mask ( ) ; try_finally ( closure , | outcome | { if let & Err ( ref error ) = outcome { let messageResult = match error . downcast_ref :: < & str > ( ) { Some ( string ) => format ! ( " " string ) , None => format ! ( " " error ) , } ; match CString :: new ( messageResult ) { Err ( _ ) => syslog2_bytes ( criticalPriority , & UnformattableFatalPanic ) , Ok ( ref message ) => syslog2_cstr ( criticalPriority , message ) } ; } unsafe { closelog ( ) ; } } ) }
Note, to log to LOG_KERN, you must specify defaultFacility: LOG_KERN, otherwise calls to syslog2(LOG_KERN) will be converted by your underlying C library to syslog2(defaultFacility)
This is because LOG_KERN is defined as 0 and the checks in nearly all system c libraries (eg musl) test for the presence of a bit pattern...
An easy way to get the progname is to use the process crate's CurrentProcess static field
Note to log to LOG_KERN you must specify defaultFacility : LOG_KERN otherwise calls to syslog2 ( LOG_KERN ) will be converted by your underlying C library to syslog2 ( defaultFacility ) This is because LOG_KERN is defined as 0 and the checks in nearly all system c libraries ( eg musl ) test for the presence of a bit pattern ... An easy way to get the progname is to use the process crate ' s CurrentProcess static field
programName
&CStr
logToStandardErrorAsWell
bool
defaultFacility
Facility
closure
F
programName
&CStr
logToStandardErrorAsWell
bool
defaultFacility
Facility
closure
F