MCPcopy Index your code
hub / github.com/RustPython/RustPython / openlog

Function openlog

crates/stdlib/src/syslog.rs:77–97  ·  view source on GitHub ↗
(args: OpenLogArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

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 {

Callers 1

syslogFunction · 0.85

Calls 8

get_argvFunction · 0.85
global_identFunction · 0.85
SomeClass · 0.50
mapMethod · 0.45
flattenMethod · 0.45
to_cstringMethod · 0.45
writeMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected