@@ -62,6 +62,10 @@ pub enum BaseDirectory {
6262 App ,
6363 /// The current working directory.
6464 Current ,
65+ /// The Log directory.
66+ /// Resolves to [`BaseDirectory::Home/Library/Logs/{bundle_identifier}`] on macOS
67+ /// and [`BaseDirectory::Config/{bundle_identifier}/logs`] on linux and windows.
68+ Log ,
6569}
6670
6771/// Resolves the path with the optional base directory.
@@ -110,6 +114,7 @@ pub fn resolve_path<P: AsRef<Path>>(
110114 BaseDirectory :: Resource => resource_dir ( package_info) ,
111115 BaseDirectory :: App => app_dir ( config) ,
112116 BaseDirectory :: Current => Some ( env:: current_dir ( ) ?) ,
117+ BaseDirectory :: Log => log_dir ( config) ,
113118 } ;
114119 if let Some ( mut base_dir_path_value) = base_dir_path {
115120 // use the same path resolution mechanism as the bundler's resource injection algorithm
@@ -230,3 +235,19 @@ pub fn resource_dir(package_info: &PackageInfo) -> Option<PathBuf> {
230235pub fn app_dir ( config : & Config ) -> Option < PathBuf > {
231236 dirs_next:: config_dir ( ) . map ( |dir| dir. join ( & config. tauri . bundle . identifier ) )
232237}
238+
239+ /// Returns the path to the log directory.
240+ pub fn log_dir ( config : & Config ) -> Option < PathBuf > {
241+ #[ cfg( target_os = "macos" ) ]
242+ let path = dirs_next:: home_dir ( ) . map ( |dir| {
243+ dir
244+ . join ( "Library/Logs" )
245+ . join ( & config. tauri . bundle . identifier )
246+ } ) ;
247+
248+ #[ cfg( not( target_os = "macos" ) ) ]
249+ let path =
250+ dirs_next:: config_dir ( ) . map ( |dir| dir. join ( & config. tauri . bundle . identifier ) . join ( "logs" ) ) ;
251+
252+ path
253+ }
0 commit comments