use of com.cosylab.logging.engine.audience.Audience.AudienceInfo 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);
}
}
use of com.cosylab.logging.engine.audience.Audience.AudienceInfo in project ACS by ACS-Community.
the class LoggingClient method initAudience.
/**
* Init the audience.
* <P>
* If an audience has been specified in the command line then
* it will be used otherwise it tries to check if a java property
* has been set.
* <BR>
* The audience dafaults to ENGINEER.
*
* @param audienceInfo The audience: it can be <code>null</code>.
*/
protected void initAudience(AudienceInfo audienceInfo) {
AudienceInfo aInfo = null;
if (audienceInfo != null) {
// Audience set in the command line
aInfo = audienceInfo;
} else {
String audienceProp = System.getProperty(AUDIENCE_PROPERTY);
if (audienceProp == null || audienceProp.isEmpty()) {
menuBar.getEngineeringMode().doClick();
return;
}
aInfo = AudienceInfo.fromShortName(audienceProp);
if (aInfo == null) {
// Invalid property name
System.err.println(audienceProp + " is not a valid audience: using default audience");
System.err.println("Available audiences are: ");
for (String aShortName : AudienceInfo.getShortNames()) {
System.err.println("\t" + aShortName);
}
menuBar.getEngineeringMode().doClick();
return;
}
}
switch(aInfo) {
case ENGINEER:
{
menuBar.getEngineeringMode().doClick();
return;
}
case OPERATOR:
{
menuBar.getOperatorMode().doClick();
return;
}
case SCILOG:
{
menuBar.getSciLogMode().doClick();
return;
}
default:
{
// Unknown audience
menuBar.getEngineeringMode().doClick();
return;
}
}
}
Aggregations