{"record":{"id":"d7785e1d47b95124","repo":"dmtrKovalenko/fff","slug":"failed-to-init-tracing","errorCode":null,"errorMessage":"Failed to init tracing: {}","messagePattern":"Failed to init tracing: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fff-c/src/lib.rs","lineNumber":203,"sourceCode":"        return FffResult::err(\"opts is null\");\n    }\n    let opts = unsafe { &*opts };\n    if opts.version == 0 || opts.version > FFF_CREATE_OPTIONS_VERSION {\n        return FffResult::err(&format!(\n            \"Unsupported FffCreateOptions version {} (library understands up to {})\",\n            opts.version, FFF_CREATE_OPTIONS_VERSION\n        ));\n    }\n\n    let base_path_str = match unsafe { cstr_to_str(opts.base_path) } {\n        Some(s) if !s.is_empty() => s.to_string(),\n        _ => return FffResult::err(\"opts.base_path is null or empty\"),\n    };\n\n    if let Some(log_path) = unsafe { optional_cstr(opts.log_file_path) } {\n        let level = unsafe { optional_cstr(opts.log_level) };\n        if let Err(e) = fff::log::init_tracing(log_path, level, None) {\n            return FffResult::err(&format!(\"Failed to init tracing: {}\", e));\n        }\n    }\n\n    let frecency_path = unsafe { optional_cstr(opts.frecency_db_path) }.map(|s| s.to_string());\n    let history_path = unsafe { optional_cstr(opts.history_db_path) }.map(|s| s.to_string());\n\n    let shared_picker = SharedFilePicker::default();\n    let shared_frecency = SharedFrecency::default();\n    let query_tracker = SharedQueryTracker::default();\n\n    if let Some(ref frecency_path) = frecency_path {\n        if let Some(parent) = PathBuf::from(frecency_path).parent() {\n            let _ = std::fs::create_dir_all(parent);\n        }\n\n        match FrecencyTracker::open(frecency_path) {\n            Ok(tracker) => {\n                if let Err(e) = shared_frecency.init(tracker) {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/dmtrKovalenko/fff/blob/7f8537e70f0ea1210f9acbbfc4640141105cdc78/crates/fff-c/src/lib.rs#L185-L221","documentation":"When opts.log_file_path is provided, the library initializes its tracing/logging subsystem via fff::log::init_tracing. If that initialization fails (the underlying error is embedded in the message), instance creation aborts rather than continuing without logging.","triggerScenarios":"Passing a log_file_path whose directory does not exist or is not writable; an invalid log_level string; the log file being locked/unwritable on disk.","commonSituations":"Pointing logs at a read-only directory or a path outside the sandbox; typos in log_level (must be a valid tracing level like 'debug'); container users mapping a read-only volume for the log path.","solutions":["Create the parent directory of log_file_path and ensure it is writable.","Use a valid log_level value ('trace','debug','info','warn','error') or pass NULL.","Point log_file_path at a writable location (e.g. tmp dir) to isolate the issue.","Omit log_file_path (NULL) to skip logging setup entirely if logging is optional."],"exampleFix":"// before\nopts.log_file_path = \"/var/log/fff.log\"; // read-only for the user\n// after\nmkdirp(\"/home/me/.cache/fff\");\nopts.log_file_path = \"/home/me/.cache/fff/fff.log\";\nopts.log_level = \"debug\";","handlingStrategy":"try-catch","validationCode":"const fs = require('fs');\nif (logPath) fs.mkdirSync(path.dirname(logPath), { recursive: true });\nif (logLevel && !['trace','debug','info','warn','error'].includes(logLevel.toLowerCase())) throw new Error(`invalid log_level: ${logLevel}`);","typeGuard":null,"tryCatchPattern":"try {\n  createInstance({ ...opts, log_file_path: logPath });\n} catch (e) {\n  if (/Failed to init tracing/.test(e.message)) {\n    createInstance({ ...opts, log_file_path: null }); // proceed without logging\n  } else throw e;\n}","preventionTips":["Create the log directory before init.","Use only valid tracing level names.","Keep log paths in writable user dirs, not system dirs.","Treat logging as optional; drop it if init fails."],"tags":["logging","ffi","rust","file-io"],"backgroundTag":"file-open-failed","analyzedSha":"7f8537e70f0ea1210f9acbbfc4640141105cdc78","analyzedAt":"2026-09-10T07:26:53.407Z","contentChangedAt":"2026-09-10T07:26:53.407Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}