mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Updates pull request from Roman Tsypuk to convert the build system from
ant to gradle. Removes linux and windows application launch scripts and produces an executable jar with all resources included.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.log;
|
||||
|
||||
import io.github.dsheirer.module.decode.event.ICallEventListener;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.module.decode.event.CallEvent;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class CallEventLogger extends EventLogger implements ICallEventListener,
|
||||
Listener<CallEvent>
|
||||
{
|
||||
public CallEventLogger( Path logDirectory, String fileNameSuffix )
|
||||
{
|
||||
super( logDirectory, fileNameSuffix );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( CallEvent callEvent )
|
||||
{
|
||||
write( callEvent.toCSV() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader()
|
||||
{
|
||||
return CallEvent.getCSVHeader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<CallEvent> getCallEventListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
super.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.log;
|
||||
|
||||
import io.github.dsheirer.controller.channel.Channel;
|
||||
import io.github.dsheirer.gui.editor.Editor;
|
||||
import io.github.dsheirer.module.log.config.EventLogConfiguration;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
public class EventLogConfigurationEditor extends Editor<Channel>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JCheckBox mBinaryLogger;
|
||||
private JCheckBox mDecodedLogger;
|
||||
private JCheckBox mCallEventLogger;
|
||||
|
||||
public EventLogConfigurationEditor()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 4", "", "[][grow]" ) );
|
||||
|
||||
mBinaryLogger = new JCheckBox( "Binary Messages" );
|
||||
mBinaryLogger.setEnabled( false );
|
||||
mBinaryLogger.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mBinaryLogger );
|
||||
|
||||
mDecodedLogger = new JCheckBox( "Decoded Messages" );
|
||||
mDecodedLogger.setEnabled( false );
|
||||
mDecodedLogger.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mDecodedLogger );
|
||||
|
||||
mCallEventLogger = new JCheckBox( "Call Events" );
|
||||
mCallEventLogger.setEnabled( false );
|
||||
mCallEventLogger.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mCallEventLogger );
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current configuration as the stored configuration
|
||||
*/
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() )
|
||||
{
|
||||
EventLogConfiguration config = getItem().getEventLogConfiguration();
|
||||
|
||||
config.clear();
|
||||
|
||||
if( mBinaryLogger.isSelected() )
|
||||
{
|
||||
config.addLogger( EventLogType.BINARY_MESSAGE );
|
||||
}
|
||||
if( mDecodedLogger.isSelected() )
|
||||
{
|
||||
config.addLogger( EventLogType.DECODED_MESSAGE );
|
||||
}
|
||||
if( mCallEventLogger.isSelected() )
|
||||
{
|
||||
config.addLogger( EventLogType.CALL_EVENT );
|
||||
}
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( Channel channel )
|
||||
{
|
||||
super.setItem( channel );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
setControlsEnabled( true );
|
||||
|
||||
List<EventLogType> loggers = getItem().getEventLogConfiguration().getLoggers();
|
||||
mBinaryLogger.setSelected( loggers.contains( EventLogType.BINARY_MESSAGE ) );
|
||||
mDecodedLogger.setSelected( loggers.contains( EventLogType.DECODED_MESSAGE ) );
|
||||
mCallEventLogger.setSelected( loggers.contains( EventLogType.CALL_EVENT ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
setControlsEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
private void setControlsEnabled( boolean enabled )
|
||||
{
|
||||
if( mBinaryLogger.isEnabled() != enabled )
|
||||
{
|
||||
mBinaryLogger.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mDecodedLogger.isEnabled() != enabled )
|
||||
{
|
||||
mDecodedLogger.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mCallEventLogger.isEnabled() != enabled )
|
||||
{
|
||||
mCallEventLogger.setEnabled( enabled );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.log;
|
||||
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.module.log.config.EventLogConfiguration;
|
||||
import io.github.dsheirer.properties.SystemProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class EventLogManager
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(EventLogManager.class);
|
||||
|
||||
private Path mDirectory;
|
||||
|
||||
public EventLogManager()
|
||||
{
|
||||
mDirectory = SystemProperties.getInstance()
|
||||
.getApplicationFolder( "event_logs" );
|
||||
}
|
||||
|
||||
public List<Module> getLoggers(EventLogConfiguration config, String prefix )
|
||||
{
|
||||
List<Module> loggers = new ArrayList<Module>();
|
||||
|
||||
for( EventLogType type: config.getLoggers() )
|
||||
{
|
||||
loggers.add( getLogger( type, prefix ) );
|
||||
}
|
||||
|
||||
return loggers;
|
||||
}
|
||||
|
||||
public EventLogger getLogger( EventLogType eventLogType, String prefix )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( prefix );
|
||||
sb.append( eventLogType.getFileSuffix() );
|
||||
sb.append( ".log" );
|
||||
|
||||
switch( eventLogType )
|
||||
{
|
||||
case BINARY_MESSAGE:
|
||||
return new MessageEventLogger( mDirectory, sb.toString(), MessageEventLogger.Type.BINARY );
|
||||
case DECODED_MESSAGE:
|
||||
return new MessageEventLogger( mDirectory, sb.toString(), MessageEventLogger.Type.DECODED );
|
||||
case CALL_EVENT:
|
||||
return new CallEventLogger( mDirectory, sb.toString() );
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.log;
|
||||
|
||||
|
||||
public enum EventLogType
|
||||
{
|
||||
BINARY_MESSAGE( "Binary Messages", "_binary_messages" ),
|
||||
DECODED_MESSAGE( "Decoded Messages", "_decoded_messages" ),
|
||||
CALL_EVENT( "Call Events", "_call_events" );
|
||||
|
||||
private String mDisplayString;
|
||||
private String mFileSuffix;
|
||||
|
||||
EventLogType( String displayString, String fileSuffix )
|
||||
{
|
||||
mDisplayString = displayString;
|
||||
mFileSuffix = fileSuffix;
|
||||
}
|
||||
|
||||
public String getDisplayString()
|
||||
{
|
||||
return mDisplayString;
|
||||
}
|
||||
|
||||
public String getFileSuffix()
|
||||
{
|
||||
return mFileSuffix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return mDisplayString;
|
||||
}
|
||||
}
|
||||
139
src/main/java/io/github/dsheirer/module/log/EventLogger.java
Normal file
139
src/main/java/io/github/dsheirer/module/log/EventLogger.java
Normal file
@@ -0,0 +1,139 @@
|
||||
/*******************************************************************************
|
||||
* sdrtrunk
|
||||
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.log;
|
||||
|
||||
import io.github.dsheirer.module.Module;
|
||||
import io.github.dsheirer.util.TimeStamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public abstract class EventLogger extends Module
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(EventLogger.class);
|
||||
|
||||
private static final String[] ILLEGAL_FILENAME_CHARACTERS = {"#", "%", "&", "{", "}", "\\", "<", ">",
|
||||
"*", "?", "/", " ", "$", "!", "'", "\"", ":", "@", "+", "`", "|", "="};
|
||||
|
||||
private Path mLogDirectory;
|
||||
private String mFileNameSuffix;
|
||||
private String mLogFileName;
|
||||
protected Writer mLogFile;
|
||||
|
||||
public EventLogger(Path logDirectory, String fileNameSuffix)
|
||||
{
|
||||
mLogDirectory = logDirectory;
|
||||
mFileNameSuffix = fileNameSuffix;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if(mLogFileName != null)
|
||||
{
|
||||
return mLogFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getHeader();
|
||||
|
||||
@Override
|
||||
public void start(ScheduledExecutorService executor)
|
||||
{
|
||||
if(mLogFile == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(mLogDirectory);
|
||||
sb.append(File.separator);
|
||||
sb.append(TimeStamp.getTimeStamp("_"));
|
||||
sb.append("_");
|
||||
sb.append(replaceIllegalCharacters(mFileNameSuffix));
|
||||
|
||||
mLogFileName = sb.toString();
|
||||
|
||||
mLogFile = new OutputStreamWriter(new FileOutputStream(mLogFileName));
|
||||
|
||||
write(getHeader());
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
{
|
||||
mLog.error("Couldn't create log file in directory:" + mLogDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces any illegal filename characters in the proposed filename
|
||||
*/
|
||||
private String replaceIllegalCharacters(String filename)
|
||||
{
|
||||
for(String illegalCharacter : ILLEGAL_FILENAME_CHARACTERS)
|
||||
{
|
||||
filename = filename.replace(illegalCharacter, "_");
|
||||
}
|
||||
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
if(mLogFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mLogFile.flush();
|
||||
mLogFile.close();
|
||||
mLogFile = null;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Couldn't close log file:" + mFileNameSuffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void write(String eventLogEntry)
|
||||
{
|
||||
if(mLogFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mLogFile.write(eventLogEntry + "\n");
|
||||
mLogFile.flush();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
mLog.error("Error writing entry to event log file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.log;
|
||||
|
||||
import io.github.dsheirer.message.IMessageListener;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.util.TimeStamp;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MessageEventLogger extends EventLogger implements
|
||||
IMessageListener, Listener<Message>
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
BINARY, DECODED
|
||||
};
|
||||
|
||||
private Type mType;
|
||||
|
||||
public MessageEventLogger( Path logDirectory,
|
||||
String fileNameSuffix,
|
||||
Type type )
|
||||
{
|
||||
super( logDirectory, fileNameSuffix );
|
||||
|
||||
mType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<Message> getMessageListener()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose()
|
||||
{
|
||||
super.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( Message message )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( TimeStamp.getTimeStamp( " " ) );
|
||||
sb.append( "," );
|
||||
sb.append( ( message.isValid() ? "PASSED" : "FAILED" ) );
|
||||
sb.append( "," );
|
||||
|
||||
if ( mType == Type.BINARY )
|
||||
{
|
||||
sb.append( message.getBinaryMessage() );
|
||||
} else
|
||||
{
|
||||
sb.append( message.getMessage() );
|
||||
}
|
||||
|
||||
write( sb.toString() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHeader()
|
||||
{
|
||||
return mType.toString() + " Message Logger\n";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.module.log.config;
|
||||
|
||||
import io.github.dsheirer.controller.config.Configuration;
|
||||
import io.github.dsheirer.module.log.EventLogType;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement( name = "event_log_configuration" )
|
||||
public class EventLogConfiguration extends Configuration
|
||||
{
|
||||
protected List<EventLogType> mLoggers = new ArrayList<EventLogType>();
|
||||
|
||||
public EventLogConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
@XmlElement( name = "logger" )
|
||||
public List<EventLogType> getLoggers()
|
||||
{
|
||||
return mLoggers;
|
||||
}
|
||||
|
||||
public void setLoggers( ArrayList<EventLogType> loggers )
|
||||
{
|
||||
mLoggers = loggers;
|
||||
}
|
||||
|
||||
public void addLogger( EventLogType logger )
|
||||
{
|
||||
mLoggers.add( logger );
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
mLoggers.clear();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user