22
33use built:: { BUILT_TIME_UTC , GIT_VERSION , PKG_VERSION , PROFILE , RUSTC_VERSION , TARGET } ;
44use config_wrapper:: {
5- build_config, get_config_path, get_log_path, open_config_file , write_config_file,
5+ build_config, get_config_path, get_log_path, write_config_file,
66} ;
7- #[ cfg( target_os = "macos" ) ]
8- use macos:: event_loop;
97use rhythm_doctor:: launch_rhythm_doctor;
108
119use log:: { debug, error, info, warn} ;
@@ -15,9 +13,19 @@ use std::process::ExitCode;
1513
1614mod built;
1715mod config_wrapper;
18- mod macos;
1916mod rhythm_doctor;
2017
18+ // MacOS
19+ #[ cfg( target_os = "macos" ) ]
20+ use macos:: event_loop;
21+
22+ #[ cfg( target_os = "macos" ) ]
23+ mod macos;
24+
25+ // Not MacOS
26+ #[ cfg( not( target_os = "macos" ) ) ]
27+ use config_wrapper:: open_config_file;
28+
2129/// Forward the given launch option to Rhythm Doctor.
2230fn main ( ) -> ExitCode {
2331 init_log ( ) ;
@@ -59,9 +67,12 @@ fn main() -> ExitCode {
5967
6068 let Some ( level) = args. get ( 1 ) else {
6169 info ! ( "Run with no arguments" ) ;
62- if cfg ! ( target_os = "macos" ) {
63- event_loop ( with_steam) ;
64- } else {
70+
71+ #[ cfg( target_os = "macos" ) ]
72+ event_loop ( with_steam) ;
73+
74+ #[ cfg( not( target_os = "macos" ) ) ]
75+ {
6576 info ! ( "Opening configuration file" ) ;
6677 let _ = open_config_file ( ) ;
6778 return ExitCode :: from ( 1 ) ;
@@ -74,35 +85,35 @@ fn main() -> ExitCode {
7485
7586/// Sets up logging
7687fn init_log ( ) {
77- if cfg ! ( debug_assertions) {
78- let _ = simplelog:: CombinedLogger :: init ( vec ! [
79- simplelog:: TermLogger :: new(
80- simplelog:: LevelFilter :: Trace ,
81- simplelog:: Config :: default ( ) ,
82- simplelog:: TerminalMode :: Stdout ,
83- simplelog:: ColorChoice :: Auto ,
84- ) ,
85- simplelog:: WriteLogger :: new(
86- simplelog:: LevelFilter :: Trace ,
87- simplelog:: Config :: default ( ) ,
88- std:: fs:: File :: create( get_log_path( ) ) . unwrap( ) ,
89- ) ,
90- ] ) ;
91- } else {
92- let _ = simplelog :: CombinedLogger :: init ( vec ! [
93- simplelog:: TermLogger :: new (
94- simplelog:: LevelFilter :: Info ,
95- simplelog:: Config :: default ( ) ,
96- simplelog:: TerminalMode :: Stdout ,
97- simplelog:: ColorChoice :: Auto ,
98- ) ,
99- simplelog :: WriteLogger :: new (
100- simplelog:: LevelFilter :: Info ,
101- simplelog:: Config :: default ( ) ,
102- std :: fs :: File :: create ( get_log_path ( ) ) . unwrap ( ) ,
103- ) ,
104- ] ) ;
105- }
88+ # [ cfg( debug_assertions) ]
89+ let _ = simplelog:: CombinedLogger :: init ( vec ! [
90+ simplelog:: TermLogger :: new(
91+ simplelog:: LevelFilter :: Trace ,
92+ simplelog:: Config :: default ( ) ,
93+ simplelog:: TerminalMode :: Stdout ,
94+ simplelog:: ColorChoice :: Auto ,
95+ ) ,
96+ simplelog:: WriteLogger :: new(
97+ simplelog:: LevelFilter :: Trace ,
98+ simplelog:: Config :: default ( ) ,
99+ std:: fs:: File :: create( get_log_path( ) ) . unwrap( ) ,
100+ ) ,
101+ ] ) ;
102+
103+ # [ cfg ( not ( debug_assertions ) ) ]
104+ let _ = simplelog:: CombinedLogger :: init ( vec ! [
105+ simplelog:: TermLogger :: new (
106+ simplelog:: LevelFilter :: Info ,
107+ simplelog:: Config :: default ( ) ,
108+ simplelog:: TerminalMode :: Stdout ,
109+ simplelog :: ColorChoice :: Auto ,
110+ ) ,
111+ simplelog:: WriteLogger :: new (
112+ simplelog:: LevelFilter :: Info ,
113+ simplelog :: Config :: default ( ) ,
114+ std :: fs :: File :: create ( get_log_path ( ) ) . unwrap ( ) ,
115+ ) ,
116+ ] ) ;
106117}
107118
108119fn open_rhythm_doctor_with_level ( with_steam : bool , level : & str ) -> ExitCode {
@@ -113,4 +124,4 @@ fn open_rhythm_doctor_with_level(with_steam: bool, level: &str) -> ExitCode {
113124 }
114125
115126 ExitCode :: from ( 0 )
116- }
127+ }
0 commit comments