Skip to content

Commit

Permalink
Merge pull request #1372 from ashitsalesforce/master
Browse files Browse the repository at this point in the history
logging during start and banner display changes
  • Loading branch information
ashitsalesforce authored Nov 2, 2024
2 parents 5a0f1e0 + 2f3d035 commit c937aff
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
13 changes: 7 additions & 6 deletions src/main/java/com/salesforce/dataloader/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1894,12 +1894,12 @@ private static boolean createDir(File dirPath) {
if (!dirPath.exists() || !dirPath.isDirectory()) {
isSuccessful = dirPath.mkdirs();
if (isSuccessful) {
logger.info("Created config folder: " + dirPath);
logger.debug("Created config folder: " + dirPath);
} else {
logger.info("Unable to create config folder: " + dirPath);
logger.warn("Unable to create config folder: " + dirPath);
}
} else {
logger.info("Config folder already exists: " + dirPath);
logger.debug("Config folder already exists: " + dirPath);
}
return isSuccessful;
}
Expand Down Expand Up @@ -1934,7 +1934,7 @@ public static synchronized AppConfig getInstance(Map<String, String> argMap) thr
File configFile = new File(configurationsDir.getAbsolutePath(), CONFIG_FILE);

String configFilePath = configFile.getAbsolutePath();
logger.info("Looking for file in config path: " + configFilePath);
logger.debug("Looking for file in config path: " + configFilePath);
if (!configFile.exists()) {

File defaultConfigFile = new File(configurationsDir, DEFAULT_CONFIG_FILE);
Expand Down Expand Up @@ -1965,15 +1965,16 @@ public static synchronized AppConfig getInstance(Map<String, String> argMap) thr
configFile.setWritable(true);
configFile.setReadable(true);
} else {
logger.info("User config is found in " + configFile.getAbsolutePath());
logger.debug("User config is found in " + configFile.getAbsolutePath());
}

AppConfig appConfig = null;
try {
appConfig = new AppConfig(configFilePath, argMap);
currentConfig = appConfig;
logger.info(Messages.getMessage(AppConfig.class, "configInit")); //$NON-NLS-1$
logger.debug(Messages.getMessage(AppConfig.class, "configInit")); //$NON-NLS-1$
} catch (IOException | ProcessInitializationException e) {
logger.error(e.getMessage());
throw new ConfigInitializationException(Messages.getMessage(AppConfig.class, "errorConfigLoad", configFilePath), e);
}
return appConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ public static void generateCSV(AppConfig appConfig) {
csvWriter.writeRow(row);
} catch (DataAccessObjectException e) {
logger.warn(Messages.getFormattedString("ConfigPropertyMetadata.errorOutputPropInfo", propMD.getName()));
logger.info(e.getStackTrace());
logger.warn(e.getStackTrace());
continue;
}
}
} finally {
logger.info(Messages.getFormattedString("ConfigPropertyMetadata.infoGeneratedCSVLocation", getFullPathToPropsFile(appConfig)));
logger.debug(Messages.getFormattedString("ConfigPropertyMetadata.infoGeneratedCSVLocation", getFullPathToPropsFile(appConfig)));
csvWriter.close();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void load() throws IOException {
throw new IOException(Messages.getString("LastRun.fileMissing")); //$NON-NLS-1$
}
File lastRunFile = new File(filePath, filename);
logger.info(Messages.getFormattedString("LastRun.fileInfo", lastRunFile.getAbsolutePath()));
logger.debug(Messages.getFormattedString("LastRun.fileInfo", lastRunFile.getAbsolutePath()));
if(!lastRunFile.exists()) {
lastRunFile.createNewFile();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ public static void install(Map<String, String> argsmap) {
return;
}
}
boolean hideBanner = false;

if (!hideBanner) {
logger.debug("going to show banner");
AppUtil.showBanner();
}
String installationFolderFromCommandLine = argsmap.get(AppConfig.CLI_OPTION_INSTALLATION_FOLDER_PROP);
boolean promptUserToDeleteExistingInstallationFolder = false;
if (installationFolderFromCommandLine == null || installationFolderFromCommandLine.isBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class DataLoaderRunner extends Thread {
private static final String LOCAL_SWT_DIR = "./target/";
private static final String PATH_SEPARATOR = System.getProperty("path.separator");
private static final String FILE_SEPARATOR = System.getProperty("file.separator");
private static Logger logger;
private static Logger logger = DLLogManager.getLogger(DataLoaderRunner.class);
private static int exitCode = AppUtil.EXIT_CODE_NO_ERRORS;

public void run() {
Expand All @@ -72,6 +72,10 @@ public void run() {

public static void main(String[] commandLineOptions) {
try {
Map<String, String> argsMap = AppUtil.convertCommandArgsArrayToArgMap(commandLineOptions);
if (!argsMap.containsKey(AppConfig.CLI_OPTION_SWT_NATIVE_LIB_IN_JAVA_LIB_PATH)) {
AppUtil.showBanner();
}
runApp(commandLineOptions, null);
System.exit(exitCode);
} catch (ExitException ex) {
Expand All @@ -90,7 +94,7 @@ public static IProcess runApp(String[] commandLineOptions, ILoaderProgress monit
try {
controller = Controller.getInstance(AppUtil.convertCommandArgsArrayToArgMap(commandLineOptions));
} catch (FactoryConfigurationError | Exception ex) {
ex.printStackTrace();
logger.fatal(ex);
System.exit(AppUtil.EXIT_CODE_CLIENT_ERROR);
}
if (AppUtil.getAppRunMode() == AppUtil.APP_RUN_MODE.BATCH) {
Expand All @@ -100,7 +104,6 @@ public static IProcess runApp(String[] commandLineOptions, ILoaderProgress monit
} else {
Map<String, String> argsMap = AppUtil.convertCommandArgsArrayToArgMap(commandLineOptions);
/* Run in the UI mode, get the controller instance with batchMode == false */
logger = DLLogManager.getLogger(DataLoaderRunner.class);
Installer.install(argsMap);
if (argsMap.containsKey(AppConfig.CLI_OPTION_SWT_NATIVE_LIB_IN_JAVA_LIB_PATH)
&& "true".equalsIgnoreCase(argsMap.get(AppConfig.CLI_OPTION_SWT_NATIVE_LIB_IN_JAVA_LIB_PATH))){
Expand All @@ -116,7 +119,6 @@ public static IProcess runApp(String[] commandLineOptions, ILoaderProgress monit
UIUtils.errorMessageBox(new Shell(new Display()), e);
}
} else { // SWT_NATIVE_LIB_IN_JAVA_LIB_PATH not set
AppUtil.showBanner();
rerunWithSWTNativeLib(commandLineOptions);
}
}
Expand Down

0 comments on commit c937aff

Please sign in to comment.