public static final String VALUE_SDKLOCATION_DEFAULT = null;;
public static final boolean VALUE_SDKUPDATE_DEFAULT = false;
+ /**
+ * Option id for getting logger level from preference store
+ */
public static final String OPTION_ID_LEVEL = "org.tizen.common.logger.level";
+
+ /**
+ * Option id for getting logger location from preference store
+ */
public static final String OPTION_ID_LOCATION = "org.tizen.common.logger.location";
+
+ /**
+ * Option id for getting logger conversion pattern from preference store
+ */
public static final String OPTION_ID_CP = "org.tizen.common.logger.cp";
+
+ /**
+ * Option id for getting report agreement from preference store
+ */
public static final String OPTION_ID_REPORT = "org.tizen.common.logger.report";
+
+ /**
+ * Option id for getting usage report agreement from preference store
+ */
public static final String OPTION_ID_USAGE = "org.tizen.common.logger.usage";
+
+ /**
+ * Option id for getting performance report agreement from preference store
+ */
public static final String OPTION_ID_PERFORM = "org.tizen.common.logger.perform";
private static final String DEFAULT_LOG_LOCATION = "%X{" + LoggerConstants.KEY_WORKSPACE + "}/.metadata/log.%d";
private static final IPreferenceStore prefStore = (CommonPlugin.getDefault() == null) ? null : CommonPlugin.getDefault().getPreferenceStore();
-
+ /**
+ * Constructor for {@link TizenBasePreferencePage}
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public TizenBasePreferencePage()
{
// super(GRID);
@Override
public void init(IWorkbench workbench) {
}
-
+
+ /**
+ * {@inheritDoc}
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
protected void createFieldEditors()
{
loggerLocText.setText(getLogLocation());
}
+ /**
+ * Gets a logger conversion pattern from the preference page
+ * @return conversion pattern
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static String getLogConversionPattern() {
String loggerCP = prefStore.getString(OPTION_ID_CP);
return loggerCP;
}
+ /**
+ * Gets a log location from the preference page
+ * @return log location
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static String getLogLocation() {
String loggerPath = prefStore.getString(OPTION_ID_LOCATION);
});
}
-
+ /**
+ * {@inheritDoc}
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
protected void performDefaults() {
super.performDefaults();
}
+ /**
+ * {@inheritDoc}
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
protected void performApply() {
prefStore.setValue(OPTION_ID_CP, loggerCP.getText());
}
+ /**
+ * {@inheritDoc}
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
public boolean performOk() {
performApply();
return super.performOk();
}
+ /**
+ * Gets a logger level from the preference store
+ * @return logger level
+ */
public static Level getLoggerLevel() {
return getLoggerLevel(null);
}
return LEVELS[DEFAULT_LEVEL];
}
+ /**
+ * Gets a reporting agreement from the preference store
+ * @return reporting agreement
+ */
public static boolean isReport() {
if(prefStore == null) {
return false;
return prefStore.getBoolean(OPTION_ID_REPORT);
}
+ /**
+ * Gets a usage reporting agreement from the preference store
+ * @return usage reporting agreement
+ */
public static boolean isUsage() {
if(prefStore == null) {
return false;
return prefStore.getBoolean(OPTION_ID_USAGE);
}
+ /**
+ * Gets a performance reporting agreement from the preference store
+ * @return performance reporting agreement
+ */
public static boolean isPerform() {
if(prefStore == null) {
return false;
* ThreadLocalMap which implements {@link Map}} has one map per one thread
* @see ThreadLocal
* @see Map
- * @author ho.namkoong
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
*/
public class ThreadLocalMap<K, V>
implements Map<K, V> {
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.ThrowableInformation;
+/**
+ * appends log to the Eclipse error log view
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ *
+ */
public class EclipseAppender extends AppenderSkeleton{
+ /**
+ * Constructor for {@link EclipseAppender}
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public EclipseAppender() {
this(new EnhancedPatternLayout(LoggerConstants.DEFAULT_CONVERSION_PATTERN));
}
+ /**
+ * Constructor for {@link EclipseAppender} with {@link Layout}
+ * @param layout
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public EclipseAppender(Layout layout) {
super();
setLayout(layout);
return false;
}
+ /**
+ * {@inheritDoc}
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
protected void append(LoggingEvent arg0) {
int level = arg0.getLevel().toInt();
import org.tizen.common.util.IOUtil;
import org.tizen.common.util.StringUtil;
+/**
+ * Appends log to the file
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ *
+ */
public class FileAppender extends AppenderSkeleton{
private int bufferSize;
private static final Timer TIMER = new Timer("File appender timer", true);
protected String logPath;
+ /**
+ * Constructor {@link FileAppender} with log path
+ * @param logPath
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public FileAppender(String logPath) {
this(logPath, new EnhancedPatternLayout(LoggerConstants.DEFAULT_CONVERSION_PATTERN), LoggerConstants.DEFAULT_BUFFER_SIZE);
}
+ /**
+ * Constructor {@link FileAppender} with log path and {@link Layout}
+ * @param logPath
+ * @param layout
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public FileAppender(String logPath, Layout layout) {
this(logPath, layout, LoggerConstants.DEFAULT_BUFFER_SIZE);
}
+ /**
+ * Constructor {@link FileAppender} with log path, {@link Layout} and buffer size
+ * @param logPath
+ * @param layout
+ * @param bufferSize
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public FileAppender(String logPath, Layout layout, int bufferSize) {
super();
this.logPath = new EnhancedPatternLayout(logPath).format(dummy);
return false;
}
+ /**
+ * Sets the log file path
+ * @param path log file path
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
synchronized public void setFilePath( final String path ) {
IOUtil.tryFlush(FILE_OUTPUT_STREAM);
IOUtil.tryClose(FILE_OUTPUT_STREAM);
initializeAppender();
}
+ /**
+ * Sets the log buffer size
+ * @param bufferSize log buffer size
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
synchronized public void setBufferSize(final int bufferSize) {
IOUtil.tryFlush(FILE_OUTPUT_STREAM);
IOUtil.tryClose(FILE_OUTPUT_STREAM);
initializeAppender();
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
synchronized protected void append(LoggingEvent arg0) {
TIMER.scheduleAtFixedRate(SCHEDULER, LoggerConstants.DEFAULT_TIMER_PERIOD, LoggerConstants.DEFAULT_TIMER_PERIOD);
}
+ /**
+ * Flush file output stream buffer for a specific time period
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ *
+ */
public class FileAppenderScheduler extends TimerTask {
@Override
public void run() {
private static final String VALUE_HIT_TYPE_APP = "appview";
int rc;
+ /**
+ * Constructor for {@link GoogleAnalyticAppender} with usage reporting agreement and performance reporting agreement
+ * @param isUsage usage reporting agreement
+ * @param isPerform performance reporting agreement
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public GoogleAnalyticAppender(boolean isUsage, boolean isPerform) {
this(isUsage, isPerform, new EnhancedPatternLayout(LoggerConstants.DEFAULT_CONVERSION_PATTERN));
}
+ /**
+ * Constructor for {@link GoogleAnalyticAppender} with usage reporting agreement, performance reporting agreement and {@link Layout}
+ * @param isUsage usage reporting agreement
+ * @param isPerform performance reporting agreement
+ * @param layout
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public GoogleAnalyticAppender(boolean isUsage, boolean isPerform, Layout layout) {
super();
this.isUsage = isUsage;
setLayout(layout);
}
+ /**
+ * Sets the usage reporting agreement
+ * @param isUsage usage reporting agreement
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public void setUsage(boolean isUsage) {
this.isUsage = isUsage;
}
+
+ /**
+ * Sets the performance reporting agreement
+ * @param isPerform performance reporting agreement
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public void setPerform(boolean isPerform) {
this.isPerform = isPerform;
}
return URLEncoder.encode( key, "utf-8" ) + "=" + URLEncoder.encode( value, "utf-8" );
}
+ /**
+ * Joins a string with "&"
+ * @param props strings which will be joined
+ * @return joined string
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
protected
String
join( String... props )
return buffer.toString();
}
+ /**
+ * {@inheritDoc}
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
protected void append(
final LoggingEvent event
package org.tizen.common.util.log;
+
public class Level extends org.apache.log4j.Level{
private static final long serialVersionUID = 5540784843364335844L;
this.description = desc;
}
+ /**
+ * Gets the description of the logger level
+ * @return logger level description
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public String getDescription() {
return description;
}
package org.tizen.common.util.log;
+import org.apache.log4j.Layout;
+
public class LoggerConstants {
+ /**
+ * Default conversion pattern
+ */
public static final String DEFAULT_CONVERSION_PATTERN = "[%p] %F(%L) - %m%n";
+
+ /**
+ * Default buffer size
+ */
public static final int DEFAULT_BUFFER_SIZE = 5000;
+
+ /**
+ * Default time period
+ */
public static final long DEFAULT_TIMER_PERIOD = 3000;
+
+ /**
+ * Default workspace key which will be used in {@link Layout}
+ */
public static final String KEY_WORKSPACE = "workspace";
+
+ /**
+ * Default sdk home key which will be used in {@link Layout}
+ */
public static final String KEY_SDK_HOME = "tizensdk";
}
import org.tizen.common.core.application.InstallPathConfig;
import org.tizen.common.ui.page.preference.TizenBasePreferencePage;
+/**
+ * Configs the tizen logger
+ *
+ *@author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public class TizenLog4jConfigurator extends DOMConfigurator implements IPropertyChangeListener {
private static Logger rootLogger;
// TODO Auto-generated method stub
}
+ /**
+ * {@inheritDoc}
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
public void doConfigure(URL arg0, LoggerRepository arg1) {
arg1.resetConfiguration();
MDC.remove(LoggerConstants.KEY_SDK_HOME);
}
+ /**
+ * {@inheritDoc}
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
import org.tizen.common.util.StringUtil;
import org.tizen.common.util.ThreadLocalMap;
+/**
+ * Logger for reporting usage and performance
+ *
+ *@author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public class UserLogger {
protected static ThreadLocalMap<String, Long> id2perform = new ThreadLocalMap<String, Long>();
private static Logger logger = Logger.getLogger(NAME_USER_LOGGER);
+ /**
+ * Report page information with a category
+ * @param category
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void page(String category) {
page(category, null);
}
+ /**
+ * Report page information with a category and exception.
+ * @param category
+ * @param t
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void page(String category, Throwable t) {
if (Level.PAGE.isGreaterOrEqual(logger.getEffectiveLevel())) {
Page message = new Page(category);
}
}
+ /**
+ * Report event information with a category
+ * @param category
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void event(String category) {
event(category, StringUtil.EMPTY_STRING, null);
}
+ /**
+ * Report event information with a category and action
+ * @param category
+ * @param action
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void event(String category, String action) {
event(category, action, null);
}
+ /**
+ * Report event information with a category, action and exception
+ * @param category
+ * @param action
+ * @param t
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void event(String category, String action, Throwable t) {
if (Level.EVENT.isGreaterOrEqual(logger.getEffectiveLevel())) {
Event message = new Event(category, action);
}
}
+ /**
+ * Report performance start information with a category
+ * @param category
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void start(String category) {
start(category, StringUtil.EMPTY_STRING);
}
+ /**
+ * Report performance start information with a category and variable name
+ * @param category
+ * @param variableName
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void start(String category, String variableName) {
if(Level.PERFORM_START.isGreaterOrEqual(logger.getEffectiveLevel())) {
}
}
+ /**
+ * Report performance end information with a category
+ * @param category
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void end(String category) {
end(category, StringUtil.EMPTY_STRING);
}
+ /**
+ * Report performance end information with a category and variable name
+ * @param category
+ * @param variableName
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static void end(String category, String variableName) {
if (Level.PERFORM_END.isGreaterOrEqual(logger.getEffectiveLevel())) {
long end = System.currentTimeMillis();
}
}
+ /**
+ * Performance information
+ *
+ *@author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static class PerformanceInfo {
final private String category;
final private String variableName;
final private String message;
+ /**
+ * Constructor for a {@link PerformanceInfo} with a category, start time and end time
+ * @param category
+ * @param start
+ * @param end
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public PerformanceInfo(String category, long start, long end) {
this(category, start, end, null);
}
+ /**
+ * Constructor for a {@link PerformanceInfo} with a category, start time, end time and variable name
+ * @param category
+ * @param start
+ * @param end
+ * @param variableName
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public PerformanceInfo(String category, long start, long end, String variableName) {
this.category = category;
this.start = start;
return this.message;
}
+ /**
+ * Gets the category
+ * @return category
+ */
public String getCategory() {
return category;
}
+ /**
+ * Gets the variable name
+ * @return variable name
+ */
public String getVariableName() {
return variableName;
}
+ /**
+ * Gets the performance time
+ * @return performance time
+ */
public String getPerformanceString() {
return String.format("%d", (this.end - this.start));
}
}
+ /**
+ * Event information
+ *
+ *@author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public static class Event {
final private String category;
final private String action;
final private String message;
+ /**
+ * Constructor for the {@link Event} with a category
+ * @param category
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public Event(String category) {
this(category, null);
}
+ /**
+ * Constructor for the {@link Event} with a category and action
+ * @param category
+ * @param action
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public Event(String category, String action) {
this.category = category;
this.action = action;
}
+ /**
+ * Gets the category
+ * @return category
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public String getCategory() {
return category;
}
+ /**
+ * Gets the action
+ * @return action
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ */
public String getAction() {
return action;
}
}
}
+ /**
+ * Page information
+ *
+ * @author Ho Namkoong {@literal <ho.namkoong@samsung.com>} (S-Core)
+ *
+ */
public static class Page {
final private String category;
final private String message;
+ /**
+ * Constructor for a {@link Page}
+ * @param category
+ */
public Page(String category) {
this.category = category;
this.message = String.format("[Category: %s]",
this.category);
}
+ /**
+ * Gets the category
+ * @return category
+ */
public String getCategory() {
return category;
}