diff --git a/build.gradle b/build.gradle index 9fa1c4d9b34b..562102a705a3 100644 --- a/build.gradle +++ b/build.gradle @@ -122,18 +122,20 @@ dependencies { compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4' compile 'org.fxmisc.richtext:richtextfx:0.7-M5' - + // Logging compile 'commons-logging:commons-logging:1.2' + compile 'org.apache.logging.log4j:log4j-jcl:2.8.2' + compile 'org.apache.logging.log4j:log4j-api:2.8.2' + compile 'org.apache.logging.log4j:log4j-core:2.8.2' + compile 'com.jcabi:jcabi-log:0.17.2' + // TODO: This should be replaced with Google Guava compile 'org.apache.commons:commons-lang3:3.6' compile 'org.jsoup:jsoup:1.10.3' compile 'com.mashape.unirest:unirest-java:1.4.9' compile 'info.debatty:java-string-similarity:0.24' - compile 'org.apache.logging.log4j:log4j-jcl:2.8.2' - compile 'org.apache.logging.log4j:log4j-api:2.8.2' - compile 'org.apache.logging.log4j:log4j-core:2.8.2' compile 'org.xmlunit:xmlunit-core:2.3.0' compile 'org.xmlunit:xmlunit-matchers:2.3.0' diff --git a/src/main/java/org/jabref/JabRefException.java b/src/main/java/org/jabref/JabRefException.java index 42eacc77c72e..9aab1ee1fd15 100644 --- a/src/main/java/org/jabref/JabRefException.java +++ b/src/main/java/org/jabref/JabRefException.java @@ -1,11 +1,9 @@ package org.jabref; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; public class JabRefException extends Exception { - private static final Log LOGGER = LogFactory.getLog(JabRefException.class); private String localizedMessage; public JabRefException(String message) { @@ -33,7 +31,7 @@ public JabRefException(Throwable cause) { @Override public String getLocalizedMessage() { if (localizedMessage == null) { - LOGGER.debug("No localized message exception message defined. Falling back to getMessage()."); + Logger.debug(this, "No localized message exception message defined. Falling back to getMessage()."); return getMessage(); } else { return localizedMessage; diff --git a/src/main/java/org/jabref/JabRefExecutorService.java b/src/main/java/org/jabref/JabRefExecutorService.java index 3c587eaebe57..77d261581111 100644 --- a/src/main/java/org/jabref/JabRefExecutorService.java +++ b/src/main/java/org/jabref/JabRefExecutorService.java @@ -9,9 +9,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - +import com.jcabi.log.Logger; /** * Responsible for managing of all threads (except Swing threads) in JabRef @@ -19,7 +17,6 @@ public class JabRefExecutorService implements Executor { public static final JabRefExecutorService INSTANCE = new JabRefExecutorService(); - private static final Log LOGGER = LogFactory.getLog(JabRefExecutorService.class); private final ExecutorService executorService = Executors.newCachedThreadPool(r -> { Thread thread = new Thread(r); thread.setName("JabRef CachedThreadPool"); @@ -41,7 +38,7 @@ private JabRefExecutorService() { } @Override public void execute(Runnable command) { if (command == null) { - LOGGER.debug("Received null as command for execution"); + Logger.debug(this, "Received null as command for execution"); return; } @@ -50,7 +47,7 @@ public void execute(Runnable command) { public void executeAndWait(Runnable command) { if (command == null) { - LOGGER.debug("Received null as command for execution"); + Logger.debug(this, "Received null as command for execution"); return; } @@ -62,14 +59,14 @@ public void executeAndWait(Runnable command) { } catch (InterruptedException ignored) { // Ignored } catch (ExecutionException e) { - LOGGER.error("Problem executing command", e); + Logger.error(this, "Problem executing command", e); } } } public boolean executeAndWait(Callable command) { if (command == null) { - LOGGER.debug("Received null as command for execution"); + Logger.debug(this, "Received null as command for execution"); return false; } @@ -81,7 +78,7 @@ public boolean executeAndWait(Callable command) { } catch (InterruptedException ignored) { // Ignored } catch (ExecutionException e) { - LOGGER.error("Problem executing command", e); + Logger.error(this, "Problem executing command", e); return false; } } @@ -97,7 +94,7 @@ public void executeInterruptableTask(final Runnable runnable, String taskName) { public void executeInterruptableTaskAndWait(Runnable runnable) { if (runnable == null) { - LOGGER.debug("Received null as command for execution"); + Logger.debug(this, "Received null as command for execution"); return; } @@ -109,7 +106,7 @@ public void executeInterruptableTaskAndWait(Runnable runnable) { } catch (InterruptedException ignored) { // Ignored } catch (ExecutionException e) { - LOGGER.error("Problem executing command", e); + Logger.error(this, "Problem executing command", e); } } } diff --git a/src/main/java/org/jabref/JabRefGUI.java b/src/main/java/org/jabref/JabRefGUI.java index b5674c29c646..97cf53cb8542 100644 --- a/src/main/java/org/jabref/JabRefGUI.java +++ b/src/main/java/org/jabref/JabRefGUI.java @@ -35,13 +35,11 @@ import org.jabref.shared.exception.InvalidDBMSConnectionPropertiesException; import org.jabref.shared.exception.NotASharedDatabaseException; +import com.jcabi.log.Logger; import com.jgoodies.looks.plastic.Plastic3DLookAndFeel; import com.jgoodies.looks.plastic.theme.SkyBluer; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class JabRefGUI { - private static final Log LOGGER = LogFactory.getLog(JabRefGUI.class); private static JabRefFrame mainFrame; @@ -96,7 +94,7 @@ private void openWindow() { GUIGlobals.init(); - LOGGER.debug("Initializing frame"); + Logger.debug(this, "Initializing frame"); JabRefGUI.mainFrame = new JabRefFrame(); // Add all bibDatabases databases to the frame: @@ -120,7 +118,7 @@ private void openWindow() { pr.getDatabaseContext().clearDatabaseFile(); // do not open the original file pr.getDatabase().clearSharedDatabaseID(); - LOGGER.error("Connection error", e); + Logger.error(this, "Connection error", e); JOptionPane.showMessageDialog(mainFrame, e.getMessage() + "\n\n" + Localization.lang("A local copy will be opened."), Localization.lang("Connection error"), JOptionPane.WARNING_MESSAGE); @@ -182,7 +180,7 @@ private void openWindow() { OpenDatabaseAction.performPostOpenActions(panel, pr); } - LOGGER.debug("Finished adding panels"); + Logger.debug(this, "Finished adding panels"); if (!bibDatabases.isEmpty()) { JabRefGUI.getMainFrame().getCurrentBasePanel().getMainTable().requestFocus(); @@ -211,7 +209,7 @@ private void openLastEditedDatabases() { Globals.prefs.getImportFormatPreferences()); if (parsedDatabase.isEmpty()) { - LOGGER.error(Localization.lang("Error opening file") + " '" + dbFile.getPath() + "'"); + Logger.error(this, Localization.lang("Error opening file") + " '" + dbFile.getPath() + "'"); } else { bibDatabases.add(parsedDatabase); } @@ -238,7 +236,7 @@ private void setLookAndFeel() { if (System.getProperty("java.runtime.name").contains("OpenJDK")) { // Metal L&F lookFeel = UIManager.getCrossPlatformLookAndFeelClassName(); - LOGGER.warn( + Logger.warn(this, "There seem to be problems with OpenJDK and the default GTK Look&Feel. Using Metal L&F instead. Change to another L&F with caution."); } else { lookFeel = systemLookFeel; @@ -269,11 +267,11 @@ private void setLookAndFeel() { Localization .lang("Unable to find the requested look and feel and thus the default one is used."), Localization.lang("Warning"), JOptionPane.WARNING_MESSAGE); - LOGGER.warn("Unable to find requested look and feel", e); + Logger.warn(this, "Unable to find requested look and feel", e); } } } catch (Exception e) { - LOGGER.warn("Look and feel could not be set", e); + Logger.warn(this, "Look and feel could not be set", e); } // In JabRef v2.8, we did it only on NON-Mac. Now, we try on all platforms diff --git a/src/main/java/org/jabref/cli/ArgumentProcessor.java b/src/main/java/org/jabref/cli/ArgumentProcessor.java index 1d11dcc723f6..2ca3c6985837 100644 --- a/src/main/java/org/jabref/cli/ArgumentProcessor.java +++ b/src/main/java/org/jabref/cli/ArgumentProcessor.java @@ -51,13 +51,11 @@ import org.jabref.preferences.SearchPreferences; import org.jabref.shared.prefs.SharedDatabasePreferences; +import com.jcabi.log.Logger; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class ArgumentProcessor { - private static final Log LOGGER = LogFactory.getLog(ArgumentProcessor.class); private final JabRefCLI cli; private final List parserResults; private final Mode startupMode; @@ -210,13 +208,13 @@ private List processArguments() { } } - LOGGER.debug("Finished export"); + Logger.debug(this, "Finished export"); if (cli.isPreferencesExport()) { try { Globals.prefs.exportPreferences(cli.getPreferencesExport()); } catch (JabRefException ex) { - LOGGER.error("Cannot export preferences", ex); + Logger.error(this, "Cannot export preferences", ex); } } @@ -470,7 +468,7 @@ private void importPreferences() { SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); } catch (JabRefException ex) { - LOGGER.error("Cannot import preferences", ex); + Logger.error(this, "Cannot import preferences", ex); } } @@ -482,7 +480,7 @@ private void resetPreferences(String value) { new SharedDatabasePreferences().clear(); } catch (BackingStoreException e) { System.err.println(Localization.lang("Unable to clear preferences.")); - LOGGER.error("Unable to clear preferences", e); + Logger.error(this, "Unable to clear preferences", e); } } else { String[] keys = value.split(","); @@ -500,7 +498,7 @@ private void resetPreferences(String value) { private void automaticallySetFileLinks(List loaded) { for (ParserResult parserResult : loaded) { BibDatabase database = parserResult.getDatabase(); - LOGGER.info(Localization.lang("Automatically setting file links")); + Logger.info(this, Localization.lang("Automatically setting file links")); AutoSetLinks.autoSetLinks(database.getEntries(), parserResult.getDatabaseContext()); } } @@ -511,7 +509,7 @@ private void regenerateBibtexKeys(List loaded) { MetaData metaData = parserResult.getMetaData(); if (metaData != null) { - LOGGER.info(Localization.lang("Regenerating BibTeX keys according to metadata")); + Logger.info(this, Localization.lang("Regenerating BibTeX keys according to metadata")); for (BibEntry entry : database.getEntries()) { // try to make a new label BibtexKeyPatternUtil.makeAndSetLabel( @@ -519,7 +517,7 @@ private void regenerateBibtexKeys(List loaded) { database, entry, Globals.prefs.getBibtexKeyPatternPreferences()); } } else { - LOGGER.info(Localization.lang("No meta data present in BIB_file. Cannot regenerate BibTeX keys")); + Logger.info(this, Localization.lang("No meta data present in BIB_file. Cannot regenerate BibTeX keys")); } } } diff --git a/src/main/java/org/jabref/cli/JabRefCLI.java b/src/main/java/org/jabref/cli/JabRefCLI.java index 0aa5be8d7a0c..7c2b2d789e5d 100644 --- a/src/main/java/org/jabref/cli/JabRefCLI.java +++ b/src/main/java/org/jabref/cli/JabRefCLI.java @@ -7,18 +7,16 @@ import org.jabref.logic.exporter.ExportFormats; import org.jabref.logic.l10n.Localization; +import com.jcabi.log.Logger; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class JabRefCLI { - private static final Log LOGGER = LogFactory.getLog(JabRefCLI.class); private List leftOver; private final CommandLine cl; @@ -32,7 +30,7 @@ public JabRefCLI(String[] args) { this.cl = new DefaultParser().parse(options, args); this.leftOver = Arrays.asList(cl.getArgs()); } catch (ParseException e) { - LOGGER.warn("Problem parsing arguments", e); + Logger.warn(this, "Problem parsing arguments", e); this.printUsage(); throw new RuntimeException(); diff --git a/src/main/java/org/jabref/collab/ChangeScanner.java b/src/main/java/org/jabref/collab/ChangeScanner.java index c413b583d677..f31c082dde3a 100644 --- a/src/main/java/org/jabref/collab/ChangeScanner.java +++ b/src/main/java/org/jabref/collab/ChangeScanner.java @@ -39,11 +39,9 @@ import org.jabref.model.groups.GroupTreeNode; import org.jabref.model.metadata.MetaData; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; public class ChangeScanner implements Runnable { - private static final Log LOGGER = LogFactory.getLog(ChangeScanner.class); private static final String[] SORT_BY = new String[] {FieldName.YEAR, FieldName.AUTHOR, FieldName.TITLE}; @@ -115,7 +113,7 @@ public void run() { scanGroups(metadataInTemp, metadataOnDisk); } catch (IOException ex) { - LOGGER.warn("Problem running", ex); + Logger.warn(this, "Problem running", ex); } } @@ -155,7 +153,7 @@ private void storeTempDatabase() { SaveSession ss = databaseWriter.saveDatabase(new BibDatabaseContext(databaseInTemp, metadataInTemp, defaults), prefs); ss.commit(Globals.getFileUpdateMonitor().getTempFile(panel.fileMonitorHandle())); } catch (SaveException ex) { - LOGGER.warn("Problem updating tmp file after accepting external changes", ex); + Logger.warn(this, "Problem updating tmp file after accepting external changes", ex); } }); } diff --git a/src/main/java/org/jabref/collab/EntryChange.java b/src/main/java/org/jabref/collab/EntryChange.java index 7efd5b411265..d3424458c144 100644 --- a/src/main/java/org/jabref/collab/EntryChange.java +++ b/src/main/java/org/jabref/collab/EntryChange.java @@ -18,12 +18,10 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; class EntryChange extends Change { - private static final Log LOGGER = LogFactory.getLog(EntryChange.class); public EntryChange(BibEntry memEntry, BibEntry tmpEntry, BibEntry diskEntry) { super(); @@ -42,7 +40,7 @@ public EntryChange(BibEntry memEntry, BibEntry tmpEntry, BibEntry diskEntry) { // in the same way. Check for this, too. boolean modificationsAgree = (DuplicateCheck.compareEntriesStrictly(memEntry, diskEntry) > 1); - LOGGER.debug("Modified entry: " + memEntry.getCiteKeyOptional().orElse("") + Logger.debug(this, "Modified entry: " + memEntry.getCiteKeyOptional().orElse("") + "\n Modified locally: " + isModifiedLocally + " Modifications agree: " + modificationsAgree); Set allFields = new TreeSet<>(); diff --git a/src/main/java/org/jabref/collab/EntryDeleteChange.java b/src/main/java/org/jabref/collab/EntryDeleteChange.java index 758363e113f5..d7ffeff1569a 100644 --- a/src/main/java/org/jabref/collab/EntryDeleteChange.java +++ b/src/main/java/org/jabref/collab/EntryDeleteChange.java @@ -12,12 +12,10 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; class EntryDeleteChange extends Change { - private static final Log LOGGER = LogFactory.getLog(EntryDeleteChange.class); private final BibEntry memEntry; private final BibEntry tmpEntry; @@ -36,7 +34,7 @@ public EntryDeleteChange(BibEntry memEntry, BibEntry tmpEntry) { // Check if it has been modified locally, since last tempfile was saved. boolean isModifiedLocally = (matchWithTmp <= 1); - LOGGER.debug("Modified entry: " + memEntry.getCiteKeyOptional().orElse("") + Logger.debug(this, "Modified entry: " + memEntry.getCiteKeyOptional().orElse("") + "\n Modified locally: " + isModifiedLocally); PreviewPanel pp = new PreviewPanel(null, memEntry, null); diff --git a/src/main/java/org/jabref/collab/FileUpdateMonitor.java b/src/main/java/org/jabref/collab/FileUpdateMonitor.java index 9d009f19848e..05dadf721f40 100644 --- a/src/main/java/org/jabref/collab/FileUpdateMonitor.java +++ b/src/main/java/org/jabref/collab/FileUpdateMonitor.java @@ -8,8 +8,9 @@ import java.util.Map; import org.jabref.logic.util.io.FileUtil; +import org.jabref.logic.xmp.XMPUtil; -import org.apache.commons.logging.Log; +import com.jcabi.log.Logger; import org.apache.commons.logging.LogFactory; /** @@ -17,7 +18,6 @@ * in the file's last modification time stamp. The */ public class FileUpdateMonitor implements Runnable { - private static final Log LOGGER = LogFactory.getLog(FileUpdateMonitor.class); private static final int WAIT = 4000; private final Map entries = new HashMap<>(); @@ -29,7 +29,7 @@ private static synchronized Path getTempFile() { temporaryFile = Files.createTempFile("jabref", null); temporaryFile.toFile().deleteOnExit(); } catch (IOException ex) { - LOGGER.warn("Could not create temporary file.", ex); + LogFactory.getLog(FileUpdateMonitor.class).warn("Could not create temporary file.", ex); } return temporaryFile; } @@ -52,7 +52,7 @@ public void run() { try { Thread.sleep(WAIT); } catch (InterruptedException ex) { - LOGGER.debug("FileUpdateMonitor has been interrupted. Terminating...", ex); + Logger.debug(this, "FileUpdateMonitor has been interrupted. Terminating...", ex); return; } } @@ -119,7 +119,7 @@ public void updateTimeStamp(String key) { try { entry.updateTimeStamp(); } catch (IOException e) { - LOGGER.error("Couldn't update timestamp", e); + Logger.error(this, "Couldn't update timestamp", e); } } } diff --git a/src/main/java/org/jabref/collab/StringAddChange.java b/src/main/java/org/jabref/collab/StringAddChange.java index b2829830ca1a..686d780c5743 100644 --- a/src/main/java/org/jabref/collab/StringAddChange.java +++ b/src/main/java/org/jabref/collab/StringAddChange.java @@ -11,12 +11,10 @@ import org.jabref.model.database.KeyCollisionException; import org.jabref.model.entry.BibtexString; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; class StringAddChange extends Change { - private static final Log LOGGER = LogFactory.getLog(StringAddChange.class); private final BibtexString string; private final InfoPane tp = new InfoPane(); @@ -37,7 +35,7 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound if (panel.getDatabase().hasStringLabel(string.getName())) { // The name to change to is already in the database, so we can't comply. - LOGGER.info("Cannot add string '" + string.getName() + "' because the name " + Logger.info(this, "Cannot add string '" + string.getName() + "' because the name " + "is already in use."); } @@ -45,12 +43,12 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound panel.getDatabase().addString(string); undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), string)); } catch (KeyCollisionException ex) { - LOGGER.info("Error: could not add string '" + string.getName() + "': " + ex.getMessage(), ex); + Logger.info(this, "Error: could not add string '" + string.getName() + "': " + ex.getMessage(), ex); } try { secondary.addString(new BibtexString(string.getName(), string.getContent())); } catch (KeyCollisionException ex) { - LOGGER.info("Error: could not add string '" + string.getName() + "' to tmp database: " + ex.getMessage(), ex); + Logger.info(this, "Error: could not add string '" + string.getName() + "' to tmp database: " + ex.getMessage(), ex); } return true; } diff --git a/src/main/java/org/jabref/collab/StringChange.java b/src/main/java/org/jabref/collab/StringChange.java index c93847d716f9..bf120cae8533 100644 --- a/src/main/java/org/jabref/collab/StringChange.java +++ b/src/main/java/org/jabref/collab/StringChange.java @@ -12,12 +12,10 @@ import org.jabref.model.database.KeyCollisionException; import org.jabref.model.entry.BibtexString; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; class StringChange extends Change { - private static final Log LOGGER = LogFactory.getLog(StringChange.class); private final BibtexString string; private final String mem; private final String disk; @@ -63,7 +61,7 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound panel.getDatabase().addString(bs); undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), bs)); } catch (KeyCollisionException ex) { - LOGGER.info("Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex); + Logger.info(this, "Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex); } } else { string.setContent(disk); diff --git a/src/main/java/org/jabref/collab/StringNameChange.java b/src/main/java/org/jabref/collab/StringNameChange.java index b53e7e630989..18b15f292c79 100644 --- a/src/main/java/org/jabref/collab/StringNameChange.java +++ b/src/main/java/org/jabref/collab/StringNameChange.java @@ -12,12 +12,10 @@ import org.jabref.model.database.KeyCollisionException; import org.jabref.model.entry.BibtexString; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; class StringNameChange extends Change { - private static final Log LOGGER = LogFactory.getLog(StringNameChange.class); private final BibtexString string; private final String mem; private final String disk; @@ -42,7 +40,7 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound if (panel.getDatabase().hasStringLabel(disk)) { // The name to change to is already in the database, so we can't comply. - LOGGER.info("Cannot rename string '" + mem + "' to '" + disk + "' because the name " + Logger.info(this, "Cannot rename string '" + mem + "' to '" + disk + "' because the name " + "is already in use."); } @@ -53,7 +51,7 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound panel.getDatabase().addString(bs); undoEdit.addEdit(new UndoableInsertString(panel, panel.getDatabase(), bs)); } catch (KeyCollisionException ex) { - LOGGER.info("Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex); + Logger.info(this, "Error: could not add string '" + bs.getName() + "': " + ex.getMessage(), ex); } } else { string.setName(disk); diff --git a/src/main/java/org/jabref/collab/StringRemoveChange.java b/src/main/java/org/jabref/collab/StringRemoveChange.java index 455704722eac..edb235ffe91f 100644 --- a/src/main/java/org/jabref/collab/StringRemoveChange.java +++ b/src/main/java/org/jabref/collab/StringRemoveChange.java @@ -10,11 +10,9 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibtexString; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; class StringRemoveChange extends Change { - private static final Log LOGGER = LogFactory.getLog(StringRemoveChange.class); private final BibtexString string; private final BibtexString inMem; @@ -42,7 +40,7 @@ public boolean makeChange(BasePanel panel, BibDatabase secondary, NamedCompound panel.getDatabase().removeString(inMem.getId()); undoEdit.addEdit(new UndoableRemoveString(panel, panel.getDatabase(), string)); } catch (Exception ex) { - LOGGER.info("Error: could not add string '" + string.getName() + "': " + ex.getMessage(), ex); + Logger.info(this, "Error: could not add string '" + string.getName() + "': " + ex.getMessage(), ex); } // Update tmp database: diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index fa37f93badf1..4fabffefe483 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -142,14 +142,12 @@ import org.jabref.shared.DBMSSynchronizer; import com.google.common.eventbus.Subscribe; +import com.jcabi.log.Logger; import com.jgoodies.forms.builder.FormBuilder; import com.jgoodies.forms.layout.FormLayout; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListener { - private static final Log LOGGER = LogFactory.getLog(BasePanel.class); // Divider size for BaseFrame split pane. 0 means non-resizable. private static final int SPLIT_PANE_DIVIDER_SIZE = 4; @@ -230,7 +228,7 @@ public BasePanel(JabRefFrame frame, BibDatabaseContext bibDatabaseContext) { try { fileMonitorHandle = Globals.getFileUpdateMonitor().addUpdateListener(this, file.get()); } catch (IOException ex) { - LOGGER.warn("Could not register FileUpdateMonitor", ex); + Logger.warn(this, "Could not register FileUpdateMonitor", ex); } } else { if (bibDatabaseContext.getDatabase().hasEntries()) { @@ -541,7 +539,7 @@ public void update() { try { JabRefDesktop.openFolderAndSelectFile(f.toAbsolutePath()); } catch (IOException e) { - LOGGER.info("Could not open folder", e); + Logger.info(this, "Could not open folder", e); } } })); @@ -635,7 +633,7 @@ public void update() { } output(outputStr); } catch (Throwable ex) { - LOGGER.warn("Could not unmark", ex); + Logger.warn(this, "Could not unmark", ex); } }); @@ -946,7 +944,7 @@ private void copyKeyAndTitle() { Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader)) .getLayoutFromText(); } catch (IOException e) { - LOGGER.info("Could not get layout", e); + Logger.info(this, "Could not get layout", e); return; } @@ -1015,7 +1013,7 @@ private void openExternalFile() { */ public void runCommand(final String _command) { if (!actions.containsKey(_command)) { - LOGGER.info("No action defined for '" + _command + '\''); + Logger.info(this, "No action defined for '" + _command + '\''); return; } @@ -1031,7 +1029,7 @@ public void runCommand(final String _command) { // The call to unblock will simply hide the glasspane, so there is no harm in calling // it even if the frame hasn't been blocked. frame.unblock(); - LOGGER.error("runCommand error: " + ex.getMessage(), ex); + Logger.error(this, "runCommand error: " + ex.getMessage(), ex); } } @@ -1066,7 +1064,7 @@ private boolean saveDatabase(File file, boolean selectedOnly, Charset enc, highlightEntry(ex.getEntry()); showEntry(ex.getEntry()); } else { - LOGGER.warn("Could not save", ex); + Logger.warn(this, "Could not save", ex); } JOptionPane.showMessageDialog(frame, Localization.lang("Could not save file.") + "\n" + ex.getMessage(), @@ -1176,7 +1174,7 @@ public BibEntry newEntry(EntryType type) { return be; } catch (KeyCollisionException ex) { - LOGGER.info(ex.getMessage(), ex); + Logger.info(this, ex.getMessage(), ex); } } return null; @@ -1205,7 +1203,7 @@ public void insertEntry(final BibEntry bibEntry) { } highlightEntry(bibEntry); } catch (KeyCollisionException ex) { - LOGGER.info("Collision for bibtex key" + bibEntry.getId(), ex); + Logger.info(this, "Collision for bibtex key" + bibEntry.getId(), ex); } } } @@ -1264,7 +1262,7 @@ public void actionPerformed(ActionEvent e) { entryEditorClosing(getCurrentEditor()); break; default: - LOGGER.warn("unknown BasePanelMode: '" + mode + "', doing nothing"); + Logger.warn(this, "unknown BasePanelMode: '" + mode + "', doing nothing"); break; } } @@ -1277,7 +1275,7 @@ public void actionPerformed(ActionEvent e) { try { runCommand(Actions.CUT); } catch (Throwable ex) { - LOGGER.warn("Could not cut", ex); + Logger.warn(this, "Could not cut", ex); } } }); @@ -1288,7 +1286,7 @@ public void actionPerformed(ActionEvent e) { try { runCommand(Actions.COPY); } catch (Throwable ex) { - LOGGER.warn("Could not copy", ex); + Logger.warn(this, "Could not copy", ex); } } }); @@ -1299,7 +1297,7 @@ public void actionPerformed(ActionEvent e) { try { runCommand(Actions.PASTE); } catch (Throwable ex) { - LOGGER.warn("Could not paste", ex); + Logger.warn(this, "Could not paste", ex); } } }); @@ -1328,7 +1326,7 @@ public void keyPressed(KeyEvent e) { try { runCommand(Actions.EDIT); } catch (Throwable ex) { - LOGGER.warn("Could not run action based on key press", ex); + Logger.warn(this, "Could not run action based on key press", ex); } } } @@ -1613,7 +1611,7 @@ public void markBaseChanged() { try { SwingUtilities.invokeAndWait(() -> markBasedChangedInternal()); } catch (InvocationTargetException | InterruptedException e) { - LOGGER.info("Problem marking database as changed", e); + Logger.info(this, "Problem marking database as changed", e); } } } @@ -1670,7 +1668,7 @@ public void changeTypeOfSelectedEntries(String newType) { private void changeType(List entries, String newType) { if ((entries == null) || (entries.isEmpty())) { - LOGGER.error("At least one entry must be selected to be able to change the type."); + Logger.error(this, "At least one entry must be selected to be able to change the type."); return; } @@ -1808,7 +1806,7 @@ public void fileUpdated() { if ((getBibDatabaseContext().getDatabaseFile().isPresent()) && !FileBasedLock.waitForFileLock(getBibDatabaseContext().getDatabaseFile().get().toPath())) { // The file is locked even after the maximum wait. Do nothing. - LOGGER.error("File updated externally, but change scan failed because the file is locked."); + Logger.error(this, "File updated externally, but change scan failed because the file is locked."); // Perturb the stored timestamp so successive checks are made: Globals.getFileUpdateMonitor().perturbTimestamp(getFileMonitorHandle()); return; @@ -1842,7 +1840,7 @@ public void fileUpdated() { @Override public void fileRemoved() { - LOGGER.info("File '" + getBibDatabaseContext().getDatabaseFile().get().getPath() + "' has been deleted."); + Logger.info(this, "File '" + getBibDatabaseContext().getDatabaseFile().get().getPath() + "' has been deleted."); } /** @@ -2151,7 +2149,7 @@ public void action() { markBaseChanged(); frame.output(Localization.lang("Undo")); } catch (CannotUndoException ex) { - LOGGER.warn("Nothing to undo", ex); + Logger.warn(this, "Nothing to undo", ex); frame.output(Localization.lang("Nothing to undo") + '.'); } @@ -2202,7 +2200,7 @@ public void action() { output(Localization.lang("External viewer called") + '.'); } catch (IOException e) { output(Localization.lang("Could not open link")); - LOGGER.info("Could not open link", e); + Logger.info(this, "Could not open link", e); } } } diff --git a/src/main/java/org/jabref/gui/ClipBoardManager.java b/src/main/java/org/jabref/gui/ClipBoardManager.java index e202f51a7fa3..13cdff2623d1 100644 --- a/src/main/java/org/jabref/gui/ClipBoardManager.java +++ b/src/main/java/org/jabref/gui/ClipBoardManager.java @@ -21,11 +21,9 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.identifier.DOI; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; public class ClipBoardManager implements ClipboardOwner { - private static final Log LOGGER = LogFactory.getLog(ClipBoardManager.class); private static final Clipboard CLIPBOARD = Toolkit.getDefaultToolkit().getSystemClipboard(); @@ -59,7 +57,7 @@ public String getClipboardContents() { result = (String) contents.getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException | IOException e) { //highly unlikely since we are using a standard DataFlavor - LOGGER.info("problem with getting clipboard contents", e); + Logger.info(this, "problem with getting clipboard contents", e); } } return result; @@ -86,33 +84,33 @@ public List extractBibEntriesFromClipboard() { List contents = (List) content.getTransferData(TransferableBibtexEntry.ENTRY_FLAVOR); result = contents; } catch (UnsupportedFlavorException | ClassCastException ex) { - LOGGER.warn("Could not paste this type", ex); + Logger.warn(this, "Could not paste this type", ex); } catch (IOException ex) { - LOGGER.warn("Could not paste", ex); + Logger.warn(this, "Could not paste", ex); } } else if (content.isDataFlavorSupported(DataFlavor.stringFlavor)) { try { String data = (String) content.getTransferData(DataFlavor.stringFlavor); // fetch from doi if (DOI.parse(data).isPresent()) { - LOGGER.info("Found DOI in clipboard"); + Logger.info(this, "Found DOI in clipboard"); Optional entry = new DoiFetcher(Globals.prefs.getImportFormatPreferences()).performSearchById(new DOI(data).getDOI()); entry.ifPresent(result::add); } else { // parse bibtex string BibtexParser bp = new BibtexParser(Globals.prefs.getImportFormatPreferences()); BibDatabase db = bp.parse(new StringReader(data)).getDatabase(); - LOGGER.info("Parsed " + db.getEntryCount() + " entries from clipboard text"); + Logger.info(this, "Parsed " + db.getEntryCount() + " entries from clipboard text"); if (db.hasEntries()) { result = db.getEntries(); } } } catch (UnsupportedFlavorException ex) { - LOGGER.warn("Could not parse this type", ex); + Logger.warn(this, "Could not parse this type", ex); } catch (IOException ex) { - LOGGER.warn("Data is no longer available in the requested flavor", ex); + Logger.warn(this, "Data is no longer available in the requested flavor", ex); } catch (FetcherException ex) { - LOGGER.error("Error while fetching", ex); + Logger.error(this, "Error while fetching", ex); } } diff --git a/src/main/java/org/jabref/gui/DefaultInjector.java b/src/main/java/org/jabref/gui/DefaultInjector.java index 93845ce5dcae..83bf484e9917 100644 --- a/src/main/java/org/jabref/gui/DefaultInjector.java +++ b/src/main/java/org/jabref/gui/DefaultInjector.java @@ -10,12 +10,11 @@ import com.airhacks.afterburner.injection.Injector; import com.airhacks.afterburner.injection.PresenterFactory; -import org.apache.commons.logging.Log; +import com.jcabi.log.Logger; import org.apache.commons.logging.LogFactory; public class DefaultInjector implements PresenterFactory { - private static final Log LOGGER = LogFactory.getLog(DefaultInjector.class); /** * This method takes care of creating dependencies. @@ -39,7 +38,7 @@ private static Object createDependency(Class clazz) { try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException ex) { - LOGGER.error("Cannot instantiate dependency: " + clazz, ex); + LogFactory.getLog(DefaultInjector.class).error("Cannot instantiate dependency: " + clazz, ex); return null; } } @@ -47,7 +46,7 @@ private static Object createDependency(Class clazz) { @Override public T instantiatePresenter(Class clazz, Function injectionContext) { - LOGGER.debug("Instantiate " + clazz.getName()); + Logger.debug(this, "Instantiate " + clazz.getName()); // Use our own method to construct dependencies Injector.setInstanceSupplier(DefaultInjector::createDependency); diff --git a/src/main/java/org/jabref/gui/EntryTypeDialog.java b/src/main/java/org/jabref/gui/EntryTypeDialog.java index 27c0e5f1d55b..dd16bf294193 100644 --- a/src/main/java/org/jabref/gui/EntryTypeDialog.java +++ b/src/main/java/org/jabref/gui/EntryTypeDialog.java @@ -41,9 +41,8 @@ import org.jabref.model.entry.EntryType; import org.jabref.model.entry.IEEETranEntryTypes; +import com.jcabi.log.Logger; import com.jgoodies.forms.builder.ButtonBarBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.VerticalLayout; /** @@ -52,7 +51,6 @@ */ public class EntryTypeDialog extends JabRefDialog implements ActionListener { - private static final Log LOGGER = LogFactory.getLog(EntryTypeDialog.class); private static final int COLUMN = 3; private final JabRefFrame frame; private final CancelAction cancelAction = new CancelAction(); @@ -291,7 +289,7 @@ protected Optional doInBackground() throws Exception { try { bibEntry = fetcher.performSearchById(searchID); } catch (FetcherException e) { - LOGGER.error(e.getMessage(), e); + Logger.error(this, e.getMessage(), e); fetcherException = true; fetcherExceptionMessage = e.getMessage(); } @@ -327,7 +325,7 @@ protected void done() { generateButton.setEnabled(true); }); } catch (ExecutionException | InterruptedException e) { - LOGGER.error(String.format("Exception during fetching when using fetcher '%s' with entry id '%s'.", searchID, fetcher.getName()), e); + Logger.error(this, String.format("Exception during fetching when using fetcher '%s' with entry id '%s'.", searchID, fetcher.getName()), e); } } } diff --git a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java index 678fa5209426..3359396df246 100644 --- a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java +++ b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java @@ -82,9 +82,8 @@ import org.jabref.model.entry.FieldName; import org.jabref.preferences.JabRefPreferences; +import com.jcabi.log.Logger; import com.jgoodies.forms.builder.ButtonBarBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; /** * GUI Dialog for the feature "Find unlinked files". @@ -99,7 +98,6 @@ public class FindUnlinkedFilesDialog extends JabRefDialog { public static final String ACTION_SHORT_DESCRIPTION = Localization .lang("Searches for unlinked PDF files on the file system"); - private static final Log LOGGER = LogFactory.getLog(FindUnlinkedFilesDialog.class); private static final String GLOBAL_PREFS_WORKING_DIRECTORY_KEY = "findUnlinkedFilesWD"; private static final String GLOBAL_PREFS_DIALOG_SIZE_KEY = "findUnlinkedFilesDialogSize"; @@ -212,7 +210,7 @@ private void restoreSizeOfDialog() { String[] dim = store.split(";"); dimension = new Dimension(Integer.valueOf(dim[0]), Integer.valueOf(dim[1])); } catch (NumberFormatException ignoredEx) { - LOGGER.debug("RestoreSizeDialog Exception ", ignoredEx); + Logger.debug(this, "RestoreSizeDialog Exception ", ignoredEx); } } if (dimension != null) { @@ -938,7 +936,7 @@ public void mousePressed(MouseEvent e) { JabRefGUI.getMainFrame().getCurrentBasePanel().getBibDatabaseContext(), fnw.file.getAbsolutePath(), FieldName.PDF); } catch (IOException e1) { - LOGGER.info("Error opening file", e1); + Logger.info(this, "Error opening file", e1); } } } else { diff --git a/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java b/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java index 147df8f34f0e..049620cf98bb 100644 --- a/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java +++ b/src/main/java/org/jabref/gui/JEditorPaneWithHighlighting.java @@ -11,15 +11,12 @@ import javax.swing.text.Highlighter; import javax.swing.text.LayeredHighlighter.LayerPainter; -import org.jabref.gui.fieldeditors.JTextAreaWithHighlighting; import org.jabref.logic.search.SearchQueryHighlightListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; public class JEditorPaneWithHighlighting extends JEditorPane implements SearchQueryHighlightListener { - private static final Log LOGGER = LogFactory.getLog(JTextAreaWithHighlighting.class); public void highlightPattern(Optional highlightPattern) { Highlighter highlighter = getHighlighter(); @@ -38,7 +35,7 @@ public void highlightPattern(Optional highlightPattern) { highlighter.addHighlight(matcher.start(), matcher.end(), painter); } catch (BadLocationException ble) { // should not occur if matcher works right - LOGGER.warn("Highlighting not possible, bad location", ble); + Logger.warn(this, "Highlighting not possible, bad location", ble); } } } @@ -49,7 +46,7 @@ private String getDocumentText() { try { text = doc.getText(0, doc.getLength()); } catch (Exception e) { - LOGGER.error("Error while getting document text"); + Logger.error(this, "Error while getting document text"); text = ""; } return text; diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 1b25660beb28..cadacb309736 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -143,17 +143,15 @@ import org.jabref.preferences.SearchPreferences; import com.google.common.eventbus.Subscribe; +import com.jcabi.log.Logger; import com.jgoodies.looks.HeaderStyle; import com.jgoodies.looks.Options; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import osx.macadapter.MacAdapter; /** * The main window of the application. */ public class JabRefFrame extends JFrame implements OutputPrinter { - private static final Log LOGGER = LogFactory.getLog(JabRefFrame.class); // Frame titles. private static final String FRAME_TITLE = "JabRef"; @@ -651,7 +649,7 @@ public void windowClosing(WindowEvent e) { try { new MacAdapter().registerMacEvents(this); } catch (Exception e) { - LOGGER.fatal("Could not interface with Mac OS X methods.", e); + Logger.error(this, "Could not interface with Mac OS X methods.", e); } } @@ -1517,7 +1515,7 @@ private List collectDatabaseFilePaths() { dbPaths.add(""); } } catch (IOException ex) { - LOGGER.error("Invalid database file path: " + ex.getMessage()); + Logger.error(this, "Invalid database file path: " + ex.getMessage()); } } return dbPaths; @@ -1685,7 +1683,7 @@ private void changeBlocking(boolean blocked) { try { SwingUtilities.invokeAndWait(() -> getGlassPane().setVisible(blocked)); } catch (InvocationTargetException | InterruptedException e) { - LOGGER.error("Problem " + (blocked ? "" : "un") + "blocking UI", e); + Logger.error(this, "Problem " + (blocked ? "" : "un") + "blocking UI", e); } } } @@ -2042,10 +2040,10 @@ public void actionPerformed(ActionEvent e) { try { ((BasePanel) tabbedPane.getSelectedComponent()).runCommand(command); } catch (Throwable ex) { - LOGGER.error("Problem with executing command: " + command, ex); + Logger.error(this, "Problem with executing command: " + command, ex); } } else { - LOGGER.info("Action '" + command + "' must be disabled when no database is open."); + Logger.info(this, "Action '" + command + "' must be disabled when no database is open."); } } } @@ -2127,7 +2125,7 @@ public EditAction(String command, String menuTitle, String description, KeyStrok @Override public void actionPerformed(ActionEvent e) { - LOGGER.debug(Globals.getFocusListener().getFocused().toString()); + Logger.debug(this, Globals.getFocusListener().getFocused().toString()); JComponent source = Globals.getFocusListener().getFocused(); Action action = source.getActionMap().get(command); if (action != null) { diff --git a/src/main/java/org/jabref/gui/PreviewPanel.java b/src/main/java/org/jabref/gui/PreviewPanel.java index 848c410e1d3c..b925d8ece3de 100644 --- a/src/main/java/org/jabref/gui/PreviewPanel.java +++ b/src/main/java/org/jabref/gui/PreviewPanel.java @@ -45,15 +45,13 @@ import org.jabref.preferences.PreviewPreferences; import com.google.common.eventbus.Subscribe; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; /** * Displays an BibEntry using the given layout format. */ public class PreviewPanel extends JPanel implements SearchQueryHighlightListener, EntryContainer { - private static final Log LOGGER = LogFactory.getLog(PreviewPanel.class); /** * The bibtex entry currently shown @@ -174,7 +172,7 @@ public Dimension getPreferredScrollableViewportSize() { String address = hyperlinkEvent.getURL().toString(); JabRefDesktop.openExternalViewer(PreviewPanel.this.databaseContext.get(), address, FieldName.URL); } catch (IOException e) { - LOGGER.warn("Could not open external viewer", e); + Logger.warn(this, "Could not open external viewer", e); } } }); @@ -195,7 +193,7 @@ public void setBasePanel(BasePanel basePanel) { public void updateLayout() { if (fixedLayout) { - LOGGER.debug("cannot change the layout because the layout is fixed"); + Logger.debug(this, "cannot change the layout because the layout is fixed"); return; } @@ -229,7 +227,7 @@ private void updatePreviewLayout(String layoutFile) { .getLayoutFromText()); } catch (IOException e) { layout = Optional.empty(); - LOGGER.debug("no layout could be set", e); + Logger.debug(this, "no layout could be set", e); } } @@ -329,7 +327,7 @@ public PreviewPanel setFixedLayout(Object parameter) { basePanel.get().getCitationStyleCache().setCitationStyle((CitationStyle) parameter); } } else { - LOGGER.error("unknown style type"); + Logger.error(this, "unknown style type"); } update(); return this; @@ -357,7 +355,7 @@ public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(PreviewPanel.this, Localization.lang("Could not print preview") + ".\n" + e.getMessage(), Localization.lang("Print entry preview"), JOptionPane.ERROR_MESSAGE); - LOGGER.info("Could not print preview", e); + Logger.info(this, "Could not print preview", e); } }); } diff --git a/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java b/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java index 9e1fb4f11269..e7cb6d284107 100644 --- a/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java +++ b/src/main/java/org/jabref/gui/actions/LookupIdentifierAction.java @@ -9,12 +9,10 @@ import org.jabref.gui.worker.LookupIdentifiersWorker; import org.jabref.logic.importer.IdFetcher; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; public class LookupIdentifierAction extends MnemonicAwareAction { - private static final Log LOGGER = LogFactory.getLog(LookupIdentifierAction.class); private final JabRefFrame frame; private final IdFetcher fetcher; @@ -32,7 +30,7 @@ public void actionPerformed(ActionEvent actionEvent) { try { BasePanel.runWorker(new LookupIdentifiersWorker(frame, fetcher)); } catch (Exception e) { - LOGGER.error(e); + Logger.error(this, "worker error", e); } } } diff --git a/src/main/java/org/jabref/gui/actions/NewEntryAction.java b/src/main/java/org/jabref/gui/actions/NewEntryAction.java index 63e009fa6659..10948240f2ef 100644 --- a/src/main/java/org/jabref/gui/actions/NewEntryAction.java +++ b/src/main/java/org/jabref/gui/actions/NewEntryAction.java @@ -13,11 +13,9 @@ import org.jabref.model.entry.EntryType; import org.jabref.model.strings.StringUtil; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; public class NewEntryAction extends MnemonicAwareAction { - private static final Log LOGGER = LogFactory.getLog(NewEntryAction.class); private final JabRefFrame jabRefFrame; private String type; // The type of item to create. @@ -65,7 +63,7 @@ public void actionPerformed(ActionEvent e) { EntryTypes.getType(thisType, jabRefFrame.getCurrentBasePanel().getBibDatabaseContext().getMode()) .get()); } else { - LOGGER.info("Action 'New entry' must be disabled when no database is open."); + Logger.info(this, "Action 'New entry' must be disabled when no database is open."); } } } diff --git a/src/main/java/org/jabref/gui/autosaveandbackup/AutosaveUIManager.java b/src/main/java/org/jabref/gui/autosaveandbackup/AutosaveUIManager.java index 52efccbb5f05..806f77cf2e51 100644 --- a/src/main/java/org/jabref/gui/autosaveandbackup/AutosaveUIManager.java +++ b/src/main/java/org/jabref/gui/autosaveandbackup/AutosaveUIManager.java @@ -5,8 +5,7 @@ import org.jabref.model.database.event.AutosaveEvent; import com.google.common.eventbus.Subscribe; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.jcabi.log.Logger; /** * This class has an abstract UI role as it listens for an {@link AutosaveEvent} @@ -14,7 +13,6 @@ */ public class AutosaveUIManager { - private static final Log LOGGER = LogFactory.getLog(AutosaveUIManager.class); private final BasePanel panel; @@ -27,7 +25,7 @@ public void listen(@SuppressWarnings("unused") AutosaveEvent event) { try { new SaveDatabaseAction(panel).runCommand(); } catch (Throwable e) { - LOGGER.error("Problem occured while saving.", e); + Logger.error(this, "Problem occured while saving.", e); } } } diff --git a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java index 2fb061ee6e96..5d6d0d92e8ab 100644 --- a/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java +++ b/src/main/java/org/jabref/gui/contentselector/ContentSelectorDialog.java @@ -40,15 +40,13 @@ import org.jabref.model.metadata.ContentSelectors; import org.jabref.model.metadata.MetaData; +import com.jcabi.log.Logger; import com.jgoodies.forms.builder.ButtonBarBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class ContentSelectorDialog extends JabRefDialog { private static final String WORD_FIRSTLINE_TEXT = Localization.lang("