Search in sources :

Example 11 with LogTypeHelper

use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.

the class LogLevelSelectorPanel method actionPerformed.

/**
	 * 
	 * @see java.awt.event.ActionListener
	 */
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == applyBtn) {
        applyChanges();
    } else if (e.getSource() == refreshBtn) {
        refresh();
    } else if (e.getSource() == defaultBtn) {
        LogLevelModel llm = (LogLevelModel) table.getModel();
        llm.setAllToCommonLevels();
    } else if (e.getSource() == allLocalCB) {
        int index = allLocalCB.getSelectedIndex();
        LogTypeHelper newLvl = LogTypeHelper.values()[index];
        LogLevelModel llm = (LogLevelModel) table.getModel();
        llm.setCommonLocalLevel(newLvl);
    } else if (e.getSource() == allGlobalCB) {
        int index = allGlobalCB.getSelectedIndex();
        LogTypeHelper newLvl = LogTypeHelper.values()[index];
        LogLevelModel llm = (LogLevelModel) table.getModel();
        llm.setCommonGlobalLevel(newLvl);
    } else {
        throw new IllegalStateException("Unknown source of events: " + e.getSource());
    }
}
Also used : LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper)

Example 12 with LogTypeHelper

use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.

the class LogLevelSelectorPanel method updateMinLevels.

/**
	 *  Updates the minimum log level panel
	 */
private void updateMinLevels() {
    LogTypeHelper minLocalLevel = getMinLocalLevel();
    minLocal.setIcon(EntryTypeIcon.getIcon(minLocalLevel));
    minLocal.setText(minLocalLevel.toString());
    minLocal.repaint();
    LogTypeHelper minGlobalLevel = getMinGlobalLevel();
    minGlobal.setIcon(EntryTypeIcon.getIcon(minGlobalLevel));
    minGlobal.setText(minGlobalLevel.toString());
    minLocal.repaint();
}
Also used : LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper)

Example 13 with LogTypeHelper

use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.

the class LogTypeCellRenderer method getTableCellRendererComponent.

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    if (isSelected) {
        levelCB.setBackground(table.getSelectionBackground());
        levelCB.setForeground(table.getSelectionForeground());
    } else {
        levelCB.setBackground(table.getBackground());
        levelCB.setForeground(table.getForeground());
    }
    // Set the text
    //minimum.setText(value.toString());
    levelCB.setFont(table.getFont());
    // If the type of log is known, set the icon
    LogTypeHelper logType;
    try {
        AcsLogLevelDefinition levelDef = AcsLogLevelDefinition.fromInteger(Integer.parseInt(value.toString()));
        logType = LogTypeHelper.fromAcsCoreLevel(levelDef);
    } catch (Exception e) {
        System.err.println("Error parsing a log type: " + value.toString());
        e.printStackTrace(System.err);
        logType = null;
    }
    if (logType != null) {
        levelCB.setSelectedIndex(logType.ordinal());
    }
    return levelCB;
}
Also used : LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) AcsLogLevelDefinition(alma.acs.logging.level.AcsLogLevelDefinition)

Example 14 with LogTypeHelper

use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.

the class LogFrame method main.

/**
	 * Starts the application.
	 * @param args an array of command-line arguments
	 */
public static void main(java.lang.String[] args) {
    // Parse the command line
    CommandLineParser parser = null;
    try {
        parser = new CommandLineParser(args);
    } catch (Throwable t) {
        CommandLineParser.printUsage(t.getMessage());
        System.exit(-1);
    }
    if (parser.getHelp()) {
        CommandLineParser.printUsage(null);
        return;
    }
    /** 
		 * If it is not <code>null</code> then the user specified a file name in the
		 * command line
		 */
    String initLogFileName = parser.getFileToLoad();
    /** 
		 * If it is not <code>null</code> then the user specified a filter file name in the
		 * command line
		 */
    String initFilterFileName = parser.getFilterFileName();
    /** 
		 * If it is not <code>null</code> then the user specified an engine  filter 
		 * file name in the command line
		 */
    String initEngineFilterFileName = parser.getEngineFilterFileName();
    /**
		 *  <code>true</code> if the user do not want the logging client tries to connect to ACS 
		 *  at startup
		 */
    boolean doNotConnect = parser.isDoNotConnect();
    /**
		 * <code>true</code> if the user does not want to limit the number of logs to  keep in memory
		 */
    boolean unlimited = parser.isUnlimited();
    /**
		 * The audience set in the command line.
		 * <P>
		 * <code>null</code> if the user did not set the audience in the
		 * command line. 
		 */
    AudienceInfo audienceInfo = parser.getAudience();
    /**
		 * The initial discard level.
		 * If it not set in the command line, the logging client starts
		 * with the default discard level
		 */
    LogTypeHelper initialDiscardLevel = parser.getDiscardLevel();
    File logFile = null;
    if (initLogFileName != null) {
        // Check if the file in the cmd line is readable
        logFile = new File(initLogFileName);
        if (!logFile.exists()) {
            System.err.println("log file " + initLogFileName + " does not exist!");
            initLogFileName = null;
            System.exit(-1);
        }
        if (!logFile.canRead()) {
            System.err.println("log file " + initLogFileName + " is unreadable!");
            initLogFileName = null;
            System.exit(-1);
        }
    }
    File filterFile = null;
    if (initFilterFileName != null) {
        filterFile = new File(initFilterFileName);
        if (!filterFile.canRead()) {
            System.err.println("Filter file " + initFilterFileName + " is unreadable!");
            System.exit(-1);
        }
    }
    File engineFilterFile = null;
    if (initEngineFilterFileName != null) {
        engineFilterFile = new File(initEngineFilterFileName);
        if (!engineFilterFile.canRead()) {
            System.err.println("Filter file " + initFilterFileName + " is unreadable!");
            System.exit(-1);
        }
    }
    try {
        // Create the frame
        class FrameLauncher extends Thread {

            private final File f;

            private final File ef;

            private final String name;

            private final boolean offline;

            private final LogTypeHelper discard;

            private final boolean noLimit;

            private final AudienceInfo aInfo;

            public FrameLauncher(File fltFile, File engfltFile, String initFileName, LogTypeHelper initDiscard, boolean noACS, boolean unlimit, AudienceInfo info) {
                f = fltFile;
                ef = engfltFile;
                name = initFileName;
                discard = initDiscard;
                offline = noACS;
                noLimit = unlimit;
                aInfo = info;
            }

            public void run() {
                new LogFrame(f, ef, name, discard, offline, noLimit, aInfo);
            }
        }
        SwingUtilities.invokeLater(new FrameLauncher(filterFile, engineFilterFile, initLogFileName, initialDiscardLevel, doNotConnect, unlimited, audienceInfo));
    } catch (Throwable exception) {
        System.err.println("Exception occurred in main() of LoggingFrame");
        exception.printStackTrace(System.err);
    }
}
Also used : LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper) AudienceInfo(com.cosylab.logging.engine.audience.Audience.AudienceInfo) File(java.io.File)

Example 15 with LogTypeHelper

use of com.cosylab.logging.engine.log.LogTypeHelper in project ACS by ACS-Community.

the class LogToolBar method getLogLevelCB.

/**
     * 
     * @return The log level CB
     */
public JComboBox getLogLevelCB() {
    if (logLevelCB == null) {
        // Add the ComboBox for the log level
        LogTypeHelper[] types = LogTypeHelper.values();
        int t = 0;
        //    		for (LogTypeHelper logType: LogTypeHelper.values()) {
        //    			Descriptions[t++]=logType.logEntryType;
        //            }
        logLevelCB = new JComboBox(types);
        // Build the renderer for the combo boxes
        LogTypeRenderer rendererCB = new LogTypeRenderer();
        logLevelCB.setSelectedItem(initialLogLevel);
        logLevelCB.setEditable(false);
        logLevelCB.setMaximumRowCount(LogTypeHelper.values().length);
        logLevelCB.setRenderer(rendererCB);
    }
    return logLevelCB;
}
Also used : JComboBox(javax.swing.JComboBox) LogTypeRenderer(com.cosylab.logging.settings.LogTypeRenderer) LogTypeHelper(com.cosylab.logging.engine.log.LogTypeHelper)

Aggregations

LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)30 ILogEntry (com.cosylab.logging.engine.log.ILogEntry)8 Date (java.util.Date)6 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)5 JComboBox (javax.swing.JComboBox)5 ExactFilter (com.cosylab.logging.engine.ExactFilter)4 MinMaxFilter (com.cosylab.logging.engine.MinMaxFilter)4 LogTypeRenderer (com.cosylab.logging.settings.LogTypeRenderer)4 Filter (com.cosylab.logging.engine.Filter)3 RegExpFilter (com.cosylab.logging.engine.RegExpFilter)3 LogEntry (com.cosylab.logging.engine.log.LogEntry)3 SystemException (org.omg.CORBA.SystemException)3 LogLevels (alma.Logging.LoggingConfigurablePackage.LogLevels)2 LogLvlSelNotSupportedException (alma.acs.gui.loglevel.LogLvlSelNotSupportedException)2 AcsLogLevelDefinition (alma.acs.logging.level.AcsLogLevelDefinition)2 IsoDateFormat (alma.acs.util.IsoDateFormat)2 GridBagLayout (java.awt.GridBagLayout)2 Point (java.awt.Point)2 FieldPosition (java.text.FieldPosition)2 SimpleDateFormat (java.text.SimpleDateFormat)2