Browse Source

Fix LoggingPlugin backbuffer not working, and open/close events going to the wrong file.

pull/531/head
Shane Mc Cormack 7 years ago
parent
commit
1e04553d1a

+ 0
- 21
logging/src/main/java/com/dmdirc/addons/logging/LogFileLocator.java View File

@@ -121,27 +121,6 @@ public class LogFileLocator {
121 121
         return getPath(directory, file, user.getNickname());
122 122
     }
123 123
 
124
-    /**
125
-     * Get the name of the log file for a specific object.
126
-     *
127
-     * @param descriptor Description of the object to get a log file for.
128
-     *
129
-     * @return the name of the log file to use for this object.
130
-     */
131
-    public String getLogFile(@Nullable final String descriptor) {
132
-        final StringBuffer directory = getLogDirectory();
133
-        final StringBuffer file = new StringBuffer();
134
-        final String md5String;
135
-        if (descriptor == null) {
136
-            file.append("null.log");
137
-            md5String = "";
138
-        } else {
139
-            file.append(sanitise(descriptor.toLowerCase()));
140
-            md5String = descriptor;
141
-        }
142
-        return getPath(directory, file, md5String);
143
-    }
144
-
145 124
     /**
146 125
      * Gets the path for the given file and directory. Only intended to be used from getLogFile
147 126
      * methods.

+ 7
- 6
logging/src/main/java/com/dmdirc/addons/logging/LoggingManager.java View File

@@ -363,7 +363,8 @@ public class LoggingManager implements ConfigChangeListener {
363 363
 
364 364
     @Handler
365 365
     public void handleChannelOpened(final ChannelOpenedEvent event) {
366
-        final String filename = locator.getLogFile(event.getChannel().getName());
366
+        final String filename = locator.getLogFile(event.getChannel());
367
+        System.out.println("\tChannel opened filename: " + filename);
367 368
 
368 369
         if (autobackbuffer) {
369 370
             showBackBuffer(event.getChannel().getWindowModel(), filename);
@@ -377,7 +378,7 @@ public class LoggingManager implements ConfigChangeListener {
377 378
 
378 379
     @Handler
379 380
     public void handleChannelClosed(final ChannelClosedEvent event) {
380
-        final String filename = locator.getLogFile(event.getChannel().getName());
381
+        final String filename = locator.getLogFile(event.getChannel());
381 382
 
382 383
         synchronized (FORMAT_LOCK) {
383 384
             appendLine(filename, "*** Channel closed at: %s", OPENED_AT_FORMAT.format(new Date()));
@@ -558,18 +559,18 @@ public class LoggingManager implements ConfigChangeListener {
558 559
      * @return True if the history is available, false otherwise
559 560
      */
560 561
     protected boolean showHistory(final WindowModel target) {
561
-        final String descriptor;
562
+        final Path log;
562 563
 
563 564
         if (target instanceof GroupChat) {
564
-            descriptor = target.getName();
565
+            log = Paths.get(locator.getLogFile((GroupChat)target));
565 566
         } else if (target instanceof Query) {
566
-            descriptor = ((PrivateChat) target).getNickname();
567
+            log = Paths.get(locator.getLogFile(((PrivateChat) target).getUser()));
567 568
         } else {
568 569
             // Unknown component
569 570
             return false;
570 571
         }
571 572
 
572
-        final Path log = Paths.get(locator.getLogFile(descriptor));
573
+
573 574
 
574 575
         if (!Files.exists(log)) {
575 576
             // File doesn't exist

Loading…
Cancel
Save