terminal user interface to jujutsu. Focused on speed and clarity
9
fork

Configure Feed

Select the types of activity you want to include in your feed.

try making logs work again

+29 -27
+29 -27
jj_tui/lib/logging.ml
··· 106 106 107 107 (*tries to get the logging dir for macos and linux*) 108 108 let get_log_dir () = 109 - let os = poll_os () in 110 - let state_home = 111 - try 112 - match os with 113 - | Some "linux" -> 114 - Some (Unix.getenv "XDG_STATE_HOME") 115 - | Some "macos" -> 116 - Some "~/Library/Logs" 117 - | Some "windows" -> 118 - Some "~/AppData/Local" 109 + try 110 + let os = poll_os () in 111 + let state_home = 112 + try 113 + match os with 114 + | Some "linux" -> 115 + Sys.getenv_opt "XDG_STATE_HOME" 116 + | Some "macos" -> 117 + let pwd = Unix.getpwuid (Unix.getuid ()) in 118 + Some (pwd.pw_dir ^ "/Library/Logs") 119 + | _ -> 120 + None 121 + with 119 122 | _ -> 120 123 None 121 - with 122 - | _ -> 123 - None 124 - in 125 - let state_home = 126 - Option.bind state_home (fun x -> if Sys.is_directory x then Some x else None) 127 - in 128 - match state_home with 129 - | None -> 130 - (try 131 - Unix.mkdir "~/.jj_tui" 0o755; 132 - Some "~/.jj_tui" 133 - with 134 - | Unix.Unix_error (Unix.EEXIST, _, _) -> 135 - None) 136 - | a -> 137 - a 124 + in 125 + let state_home = 126 + Option.bind state_home (fun x -> 127 + if Sys.file_exists x && Sys.is_directory x then Some x else None) 128 + in 129 + match state_home with 130 + | None -> 131 + Unix.mkdir "~/.jj_tui" 0o755; 132 + Some "~/.jj_tui" 133 + | a -> 134 + a 135 + with 136 + |_-> 137 + None 138 138 ;; 139 139 140 140 let init_logging () = ··· 179 179 cleanup_logs (); 180 180 [%log debug "Old logs cleaned up"] 181 181 | None -> 182 + (*just no logging if we can't find a log file*) 183 + (*TODO: log to stderr *) 182 184 () 183 185 ;; 184 186 end