Changeset 921


Ignore:
Timestamp:
Nov 7, 2010, 11:03:52 AM (7 years ago)
Author:
stefan
Message:

added facility to configure log level in global.properties

Location:
trunk/src
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/de/endrullis/utils/BetterProperties2.java

    r884 r921  
    623623  public static final Range STRING        = new PString();
    624624  public static final Range SHORTCUT      = new PShortcut();
     625  public static final Range LOGLEVEL      = new PSet("<default>", "OFF", "SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST", "ALL");
    625626}
  • trunk/src/jlatexeditor/JLatexEditorJFrame.java

    r919 r921  
    5151import java.net.URI;
    5252import java.util.*;
     53import java.util.logging.ConsoleHandler;
     54import java.util.logging.Level;
     55import java.util.logging.LogManager;
     56import java.util.logging.Logger;
    5357
    5458public class JLatexEditorJFrame extends JFrame implements ActionListener, WindowListener, ChangeListener, MouseMotionListener, TreeSelectionListener, SearchChangeListener {
    5559  public static final File FILE_LAST_SESSION = new File(System.getProperty("user.home") + "/.jlatexeditor/last.session");
    5660  public static final File FILE_RECENT = new File(System.getProperty("user.home") + "/.jlatexeditor/recent");
    57   private JMenu recentFilesMenu;
    58   private ArrayList<String> recentFiles = new ArrayList<String>();
    59 
     61
     62  /** Logger. */
     63  private static Logger logger = Logger.getLogger(JLatexEditorJFrame.class.getName());
    6064  private static String version = "*Bleeding Edge*";
    6165  private static boolean updateDisabled = true;
     
    7579
    7680  private JMenuBar menuBar = null;
     81  private JMenu recentFilesMenu;
     82  private ArrayList<String> recentFiles = new ArrayList<String>();
    7783  private JTabbedPane tabbedPane = null;
    7884  private JSplitPane textToolsSplit = null;
     
    139145    */
    140146
     147    // init logging
     148    initLogging();
     149
    141150    UIManager.put("TabbedPaneUI", "util.gui.SCETabbedPaneUI");
    142151    UIManager.put("List.timeFactor", 200L);
     
    154163  }
    155164
    156   public JLatexEditorJFrame(String args[]) {
     165  private static void initLogging() {
     166    try {
     167      LogManager.getLogManager().readConfiguration(JLatexEditorJFrame.class.getResourceAsStream("/logging.properties"));
     168    } catch (IOException e) {
     169      e.printStackTrace();
     170    }
     171    String jleLogLevel = GProperties.getString("log level.jlatexeditor");
     172    if (!jleLogLevel.equals("<default>")) {
     173      Logger.getLogger("jlatexeditor").setLevel(Level.parse(jleLogLevel));
     174    }
     175    String sceLogLevel = GProperties.getString("log level.sce");
     176    if (!sceLogLevel.equals("<default>")) {
     177      Logger.getLogger("sce").setLevel(Level.parse(sceLogLevel));
     178    }
     179  }
     180
     181  public JLatexEditorJFrame(String args[]) {
    157182    super(windowTitleSuffix);
    158183    this.args = args;
     
    708733      return editor;
    709734    } catch (IOException exc) {
    710       System.out.println("Error opening file");
    711       exc.printStackTrace();
     735      logger.log(Level.SEVERE, "Error opening file", exc);
    712736    }
    713737    return null;
     
    806830          }
    807831        } catch (Exception diffException) {
    808           System.err.println("Local history, error starting diff: " + diffException.getMessage());
     832          logger.log(Level.SEVERE, "Local history, error starting diff" + diffException);
    809833        }
    810834
     
    923947  }
    924948
    925   @Override
    926   public void requestFocus() {
    927     super.requestFocus();
     949  public void bringToFront() {
     950    toFront();
    928951    getActiveEditor().getFocusedPane().requestFocus();
    929952  }
     
    10811104        ProcessUtil.exec(array, mainEditor.getFile().getParentFile());
    10821105      } catch(Exception ex) {
    1083         System.err.println("Forward search failed: " + ex.getMessage());
     1106        logger.log(Level.SEVERE, "Forward search failed", ex);
    10841107      }
    10851108    } else
     
    15531576    public void propertyChange(PropertyChangeEvent evt) {
    15541577      String shortcut = (String) evt.getNewValue();
    1555       System.out.println(shortcut);
    15561578      if (shortcut == null) {
    15571579        shortcut = "";
  • trunk/src/jlatexeditor/gproperties/GProperties.java

    r918 r921  
    4646  public static final Range STRING = BetterProperties2.STRING;
    4747  public static final Range SHORTCUT = BetterProperties2.SHORTCUT;
     48  public static final Range LOGLEVEL = BetterProperties2.LOGLEVEL;
    4849
    4950  private static final String EDITOR_FONT_NAME = "editor.font.name";
     
    195196    properties.addEntry(new Def("inverse search.port", INT_GT_0, "13231"));
    196197
     198    properties.addEntry(new Comment("\n## Debugging"));
     199    properties.addEntry(new Comment(" global log level"));
     200    properties.addEntry(new Def("log level.jlatexeditor", LOGLEVEL, "<default>"));
     201    properties.addEntry(new Def("log level.sce", LOGLEVEL, "<default>"));
     202
    197203    load();
    198204    save();
  • trunk/src/jlatexeditor/gproperties/GPropertiesCodeHelper.java

    r744 r921  
    2222  public boolean matches() {
    2323    if (super.matches()) {
    24       key = params.get(0).word;
     24      key = params.get(0).word.replaceAll("\\\\ ", " ");
    2525      value = params.get(1);
    2626
  • trunk/src/jlatexeditor/remote/MasterNode.java

    r920 r921  
    33import jlatexeditor.Doc;
    44import jlatexeditor.JLatexEditorJFrame;
    5 import jlatexeditor.gproperties.GProperties;
    65
    76import javax.swing.*;
    8 import java.awt.event.ActionEvent;
    9 import java.io.BufferedReader;
    107import java.io.File;
    118import java.io.IOException;
    12 import java.io.InputStreamReader;
    13 import java.net.InetAddress;
    149import java.net.ServerSocket;
    1510import java.net.Socket;
    16 import java.net.SocketAddress;
    1711import java.util.ArrayList;
    1812import java.util.logging.Logger;
     
    4337      SocketConnection conn = new SocketConnection(socket);
    4438      String line = conn.receive();
    45       logger.info("reading: " + line);
     39      logger.fine("reading: " + line);
    4640
    4741      if (line == null) {
     
    111105      public void run() {
    112106        jle.open(new Doc.FileDoc(file), lineNr);
    113         jle.requestFocus();
     107        jle.bringToFront();
    114108      }
    115109    });
  • trunk/src/jlatexeditor/remote/NetworkNode.java

    r918 r921  
    66import java.io.IOException;
    77import java.net.BindException;
     8import java.util.logging.Level;
    89import java.util.logging.Logger;
    910
     
    3334      // first try to start master node
    3435      try {
    35         logger.info("Running in master mode...");
     36        logger.fine("Running in master mode...");
    3637        new MasterNode(jle, PORT);
    3738      } catch (BindException e) {
    38         logger.info("Master port in use.  Working as slave.");
     39        logger.fine("Master port in use");
    3940      } catch (IOException e) {
    40         e.printStackTrace();
     41        logger.log(Level.FINE, "Connection failure in master node", e);
    4142      }
    4243
    4344      // if master node fails try to start slave node
    4445      try {
    45         logger.info("Running in slave mode...");
     46        logger.fine("Running in slave mode...");
    4647        new SlaveNode(jle, PORT);
    4748      } catch (IOException e) {
    48         e.printStackTrace();
     49        logger.log(Level.FINE, "Connection to master node failed", e);
    4950      }
    5051
    51       logger.info("Restarting network mode");
     52      logger.fine("Restarting network mode");
    5253
    5354      try {
    54         Thread.sleep(500);
     55        Thread.sleep(tries*500);
    5556      } catch (InterruptedException e) {
    5657        break;
  • trunk/src/jlatexeditor/remote/SlaveNode.java

    r920 r921  
    3434    while (true) {
    3535      String line = conn.receive();
    36       logger.info("reading: " + line);
     36      logger.fine("reading: " + line);
    3737      if (line == null) throw new IOException("InputStream closed");
    3838
     
    6565      public void run() {
    6666        jle.open(new Doc.FileDoc(file), lineNr);
    67         jle.requestFocus();
     67        jle.bringToFront();
    6868      }
    6969    });
Note: See TracChangeset for help on using the changeset viewer.