MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / getFileHandler

Method getFileHandler

src/org/opensourcephysics/controls/OSPLog.java:899–923  ·  view source on GitHub ↗

Gets the file handler using lazy instantiation. @return the Handler

()

Source from the content-addressed store, hash-verified

897 * @return the Handler
898 */
899 protected synchronized Handler getFileHandler() {
900 if(fileHandler!=null) {
901 return fileHandler;
902 }
903 try {
904 // add a file handler with file name equal to short package name
905 int i = pkgName.lastIndexOf("."); //$NON-NLS-1$
906 if(i>-1) {
907 pkgName = pkgName.substring(i+1);
908 }
909 if(logdir.endsWith(slash)) {
910 tempFileName = logdir+pkgName+".log"; //$NON-NLS-1$
911 } else {
912 tempFileName = logdir+slash+pkgName+".log"; //$NON-NLS-1$
913 }
914 fileHandler = new FileHandler(tempFileName);
915 fileHandler.setFormatter(new XMLFormatter());
916 fileHandler.setLevel(Level.ALL);
917 logger.addHandler(fileHandler);
918 logger.log(Level.INFO, "Logging to file enabled. File = "+tempFileName); //$NON-NLS-1$
919 } catch(Exception ex) {
920 ex.printStackTrace();
921 }
922 return fileHandler;
923 }
924
925 /**
926 * Creates the popup menu.

Callers 2

saveXMLMethod · 0.95
setLogToFileActionMethod · 0.95

Calls 2

setLevelMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected