(args: OpenLogArgs, vm: &VirtualMachine)
| 75 | |
| 76 | #[pyfunction] |
| 77 | fn openlog(args: OpenLogArgs, vm: &VirtualMachine) -> PyResult<()> { |
| 78 | let logoption = args.logoption.unwrap_or(0); |
| 79 | let facility = args.facility.unwrap_or(LOG_USER); |
| 80 | let ident = match args.ident.flatten() { |
| 81 | Some(args) => Some(args.to_cstring(vm)?), |
| 82 | None => get_argv(vm).map(|argv| argv.to_cstring(vm)).transpose()?, |
| 83 | } |
| 84 | .map(|ident| ident.into_boxed_c_str()); |
| 85 | |
| 86 | let ident = match ident { |
| 87 | Some(ident) => GlobalIdent::Explicit(ident), |
| 88 | None => GlobalIdent::Implicit, |
| 89 | }; |
| 90 | |
| 91 | { |
| 92 | let mut locked_ident = global_ident().write(); |
| 93 | unsafe { libc::openlog(ident.as_ptr(), logoption, facility) }; |
| 94 | *locked_ident = Some(ident); |
| 95 | } |
| 96 | Ok(()) |
| 97 | } |
| 98 | |
| 99 | #[derive(FromArgs)] |
| 100 | struct SysLogArgs { |
no test coverage detected