From: ho.namkoong Date: Fri, 12 Apr 2013 06:47:53 +0000 (+0900) Subject: [Title] Add javadoc to the logger X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=42374b9fc71e441747d0a016f0680083c3f10860;p=sdk%2Fide%2Fcommon-eplugin.git [Title] Add javadoc to the logger [Type] [Module] [Priority] [Jira#] [Redmine#] 7571 [Problem] [Cause] [Solution] [TestCase] Change-Id: I2605c269c2f70ebe9a1987ca0ee596bac2d4ea72 --- diff --git a/org.tizen.common/src/org/tizen/common/ui/page/preference/TizenBasePreferencePage.java b/org.tizen.common/src/org/tizen/common/ui/page/preference/TizenBasePreferencePage.java index 44da264..8e20df4 100644 --- a/org.tizen.common/src/org/tizen/common/ui/page/preference/TizenBasePreferencePage.java +++ b/org.tizen.common/src/org/tizen/common/ui/page/preference/TizenBasePreferencePage.java @@ -63,11 +63,34 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement 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"; @@ -85,7 +108,10 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement private static final IPreferenceStore prefStore = (CommonPlugin.getDefault() == null) ? null : CommonPlugin.getDefault().getPreferenceStore(); - + /** + * Constructor for {@link TizenBasePreferencePage} + * @author Ho Namkoong {@literal } (S-Core) + */ public TizenBasePreferencePage() { // super(GRID); @@ -98,7 +124,11 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement @Override public void init(IWorkbench workbench) { } - + + /** + * {@inheritDoc} + * @author Ho Namkoong {@literal } (S-Core) + */ @Override protected void createFieldEditors() { @@ -232,6 +262,12 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement loggerLocText.setText(getLogLocation()); } + /** + * Gets a logger conversion pattern from the preference page + * @return conversion pattern + * + * @author Ho Namkoong {@literal } (S-Core) + */ public static String getLogConversionPattern() { String loggerCP = prefStore.getString(OPTION_ID_CP); @@ -242,6 +278,12 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement return loggerCP; } + /** + * Gets a log location from the preference page + * @return log location + * + * @author Ho Namkoong {@literal } (S-Core) + */ public static String getLogLocation() { String loggerPath = prefStore.getString(OPTION_ID_LOCATION); @@ -317,7 +359,10 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement }); } - + /** + * {@inheritDoc} + * @author Ho Namkoong {@literal } (S-Core) + */ @Override protected void performDefaults() { @@ -330,6 +375,10 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement super.performDefaults(); } + /** + * {@inheritDoc} + * @author Ho Namkoong {@literal } (S-Core) + */ @Override protected void performApply() { @@ -342,12 +391,20 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement prefStore.setValue(OPTION_ID_CP, loggerCP.getText()); } + /** + * {@inheritDoc} + * @author Ho Namkoong {@literal } (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); } @@ -365,6 +422,10 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement return LEVELS[DEFAULT_LEVEL]; } + /** + * Gets a reporting agreement from the preference store + * @return reporting agreement + */ public static boolean isReport() { if(prefStore == null) { return false; @@ -372,6 +433,10 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement 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; @@ -379,6 +444,10 @@ public class TizenBasePreferencePage extends FieldEditorPreferencePage implement 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; diff --git a/org.tizen.common/src/org/tizen/common/util/ThreadLocalMap.java b/org.tizen.common/src/org/tizen/common/util/ThreadLocalMap.java index c0b1aae..6a64d81 100644 --- a/org.tizen.common/src/org/tizen/common/util/ThreadLocalMap.java +++ b/org.tizen.common/src/org/tizen/common/util/ThreadLocalMap.java @@ -35,7 +35,7 @@ import java.util.Set; * ThreadLocalMap which implements {@link Map}} has one map per one thread * @see ThreadLocal * @see Map - * @author ho.namkoong + * @author Ho Namkoong {@literal } (S-Core) */ public class ThreadLocalMap implements Map { diff --git a/org.tizen.common/src/org/tizen/common/util/log/EclipseAppender.java b/org.tizen.common/src/org/tizen/common/util/log/EclipseAppender.java index be90f21..7c5f4fc 100644 --- a/org.tizen.common/src/org/tizen/common/util/log/EclipseAppender.java +++ b/org.tizen.common/src/org/tizen/common/util/log/EclipseAppender.java @@ -32,12 +32,26 @@ import org.apache.log4j.Level; import org.apache.log4j.spi.LoggingEvent; import org.apache.log4j.spi.ThrowableInformation; +/** + * appends log to the Eclipse error log view + * @author Ho Namkoong {@literal } (S-Core) + * + */ public class EclipseAppender extends AppenderSkeleton{ + /** + * Constructor for {@link EclipseAppender} + * @author Ho Namkoong {@literal } (S-Core) + */ public EclipseAppender() { this(new EnhancedPatternLayout(LoggerConstants.DEFAULT_CONVERSION_PATTERN)); } + /** + * Constructor for {@link EclipseAppender} with {@link Layout} + * @param layout + * @author Ho Namkoong {@literal } (S-Core) + */ public EclipseAppender(Layout layout) { super(); setLayout(layout); @@ -55,6 +69,10 @@ public class EclipseAppender extends AppenderSkeleton{ return false; } + /** + * {@inheritDoc} + * @author Ho Namkoong {@literal } (S-Core) + */ @Override protected void append(LoggingEvent arg0) { int level = arg0.getLevel().toInt(); diff --git a/org.tizen.common/src/org/tizen/common/util/log/FileAppender.java b/org.tizen.common/src/org/tizen/common/util/log/FileAppender.java index 5bcc11a..2da03bf 100644 --- a/org.tizen.common/src/org/tizen/common/util/log/FileAppender.java +++ b/org.tizen.common/src/org/tizen/common/util/log/FileAppender.java @@ -44,6 +44,11 @@ import org.eclipse.osgi.util.NLS; import org.tizen.common.util.IOUtil; import org.tizen.common.util.StringUtil; +/** + * Appends log to the file + * @author Ho Namkoong {@literal } (S-Core) + * + */ public class FileAppender extends AppenderSkeleton{ private int bufferSize; @@ -73,14 +78,35 @@ public class FileAppender extends AppenderSkeleton{ 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 } (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 } (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 } (S-Core) + */ public FileAppender(String logPath, Layout layout, int bufferSize) { super(); this.logPath = new EnhancedPatternLayout(logPath).format(dummy); @@ -98,6 +124,12 @@ public class FileAppender extends AppenderSkeleton{ return false; } + /** + * Sets the log file path + * @param path log file path + * + * @author Ho Namkoong {@literal } (S-Core) + */ synchronized public void setFilePath( final String path ) { IOUtil.tryFlush(FILE_OUTPUT_STREAM); IOUtil.tryClose(FILE_OUTPUT_STREAM); @@ -106,6 +138,12 @@ public class FileAppender extends AppenderSkeleton{ initializeAppender(); } + /** + * Sets the log buffer size + * @param bufferSize log buffer size + * + * @author Ho Namkoong {@literal } (S-Core) + */ synchronized public void setBufferSize(final int bufferSize) { IOUtil.tryFlush(FILE_OUTPUT_STREAM); IOUtil.tryClose(FILE_OUTPUT_STREAM); @@ -113,6 +151,12 @@ public class FileAppender extends AppenderSkeleton{ initializeAppender(); } + + /** + * {@inheritDoc} + * + * @author Ho Namkoong {@literal } (S-Core) + */ @Override synchronized protected void append(LoggingEvent arg0) { @@ -173,6 +217,11 @@ public class FileAppender extends AppenderSkeleton{ 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 } (S-Core) + * + */ public class FileAppenderScheduler extends TimerTask { @Override public void run() { diff --git a/org.tizen.common/src/org/tizen/common/util/log/GoogleAnalyticAppender.java b/org.tizen.common/src/org/tizen/common/util/log/GoogleAnalyticAppender.java index bac9a22..35428f3 100644 --- a/org.tizen.common/src/org/tizen/common/util/log/GoogleAnalyticAppender.java +++ b/org.tizen.common/src/org/tizen/common/util/log/GoogleAnalyticAppender.java @@ -84,10 +84,25 @@ extends AppenderSkeleton 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 } (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 } (S-Core) + */ public GoogleAnalyticAppender(boolean isUsage, boolean isPerform, Layout layout) { super(); this.isUsage = isUsage; @@ -95,10 +110,23 @@ extends AppenderSkeleton setLayout(layout); } + /** + * Sets the usage reporting agreement + * @param isUsage usage reporting agreement + * + * @author Ho Namkoong {@literal } (S-Core) + */ public void setUsage(boolean isUsage) { this.isUsage = isUsage; } + + /** + * Sets the performance reporting agreement + * @param isPerform performance reporting agreement + * + * @author Ho Namkoong {@literal } (S-Core) + */ public void setPerform(boolean isPerform) { this.isPerform = isPerform; } @@ -126,6 +154,13 @@ extends AppenderSkeleton 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 } (S-Core) + */ protected String join( String... props ) @@ -143,6 +178,11 @@ extends AppenderSkeleton return buffer.toString(); } + /** + * {@inheritDoc} + * + * @author Ho Namkoong {@literal } (S-Core) + */ @Override protected void append( final LoggingEvent event diff --git a/org.tizen.common/src/org/tizen/common/util/log/Level.java b/org.tizen.common/src/org/tizen/common/util/log/Level.java index c84597d..e9f1dae 100644 --- a/org.tizen.common/src/org/tizen/common/util/log/Level.java +++ b/org.tizen.common/src/org/tizen/common/util/log/Level.java @@ -27,6 +27,7 @@ package org.tizen.common.util.log; + public class Level extends org.apache.log4j.Level{ private static final long serialVersionUID = 5540784843364335844L; @@ -93,6 +94,12 @@ public class Level extends org.apache.log4j.Level{ this.description = desc; } + /** + * Gets the description of the logger level + * @return logger level description + * + * @author Ho Namkoong {@literal } (S-Core) + */ public String getDescription() { return description; } diff --git a/org.tizen.common/src/org/tizen/common/util/log/LoggerConstants.java b/org.tizen.common/src/org/tizen/common/util/log/LoggerConstants.java index a56c862..ce06ef6 100644 --- a/org.tizen.common/src/org/tizen/common/util/log/LoggerConstants.java +++ b/org.tizen.common/src/org/tizen/common/util/log/LoggerConstants.java @@ -27,12 +27,33 @@ 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"; } diff --git a/org.tizen.common/src/org/tizen/common/util/log/TizenLog4jConfigurator.java b/org.tizen.common/src/org/tizen/common/util/log/TizenLog4jConfigurator.java index 7dedc6c..946786b 100644 --- a/org.tizen.common/src/org/tizen/common/util/log/TizenLog4jConfigurator.java +++ b/org.tizen.common/src/org/tizen/common/util/log/TizenLog4jConfigurator.java @@ -40,6 +40,11 @@ import org.eclipse.jface.util.PropertyChangeEvent; import org.tizen.common.core.application.InstallPathConfig; import org.tizen.common.ui.page.preference.TizenBasePreferencePage; +/** + * Configs the tizen logger + * + *@author Ho Namkoong {@literal } (S-Core) + */ public class TizenLog4jConfigurator extends DOMConfigurator implements IPropertyChangeListener { private static Logger rootLogger; @@ -56,6 +61,11 @@ public class TizenLog4jConfigurator extends DOMConfigurator implements IProperty // TODO Auto-generated method stub } + /** + * {@inheritDoc} + * + * @author Ho Namkoong {@literal } (S-Core) + */ @Override public void doConfigure(URL arg0, LoggerRepository arg1) { arg1.resetConfiguration(); @@ -97,6 +107,11 @@ public class TizenLog4jConfigurator extends DOMConfigurator implements IProperty MDC.remove(LoggerConstants.KEY_SDK_HOME); } + /** + * {@inheritDoc} + * + * @author Ho Namkoong {@literal } (S-Core) + */ @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); diff --git a/org.tizen.common/src/org/tizen/common/util/log/UserLogger.java b/org.tizen.common/src/org/tizen/common/util/log/UserLogger.java index b594503..fbd71f8 100644 --- a/org.tizen.common/src/org/tizen/common/util/log/UserLogger.java +++ b/org.tizen.common/src/org/tizen/common/util/log/UserLogger.java @@ -32,6 +32,11 @@ import org.apache.log4j.Logger; import org.tizen.common.util.StringUtil; import org.tizen.common.util.ThreadLocalMap; +/** + * Logger for reporting usage and performance + * + *@author Ho Namkoong {@literal } (S-Core) + */ public class UserLogger { protected static ThreadLocalMap id2perform = new ThreadLocalMap(); @@ -42,10 +47,23 @@ public class UserLogger { private static Logger logger = Logger.getLogger(NAME_USER_LOGGER); + /** + * Report page information with a category + * @param category + * + * @author Ho Namkoong {@literal } (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 } (S-Core) + */ public static void page(String category, Throwable t) { if (Level.PAGE.isGreaterOrEqual(logger.getEffectiveLevel())) { Page message = new Page(category); @@ -54,14 +72,35 @@ public class UserLogger { } } + /** + * Report event information with a category + * @param category + * + * @author Ho Namkoong {@literal } (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 } (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 } (S-Core) + */ public static void event(String category, String action, Throwable t) { if (Level.EVENT.isGreaterOrEqual(logger.getEffectiveLevel())) { Event message = new Event(category, action); @@ -69,10 +108,23 @@ public class UserLogger { } } + /** + * Report performance start information with a category + * @param category + * + * @author Ho Namkoong {@literal } (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 } (S-Core) + */ public static void start(String category, String variableName) { if(Level.PERFORM_START.isGreaterOrEqual(logger.getEffectiveLevel())) { @@ -83,10 +135,23 @@ public class UserLogger { } } + /** + * Report performance end information with a category + * @param category + * + * @author Ho Namkoong {@literal } (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 } (S-Core) + */ public static void end(String category, String variableName) { if (Level.PERFORM_END.isGreaterOrEqual(logger.getEffectiveLevel())) { long end = System.currentTimeMillis(); @@ -100,6 +165,11 @@ public class UserLogger { } } + /** + * Performance information + * + *@author Ho Namkoong {@literal } (S-Core) + */ public static class PerformanceInfo { final private String category; @@ -108,10 +178,27 @@ public class UserLogger { 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 } (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 } (S-Core) + */ public PerformanceInfo(String category, long start, long end, String variableName) { this.category = category; this.start = start; @@ -140,29 +227,59 @@ public class UserLogger { 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 } (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 } (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 } (S-Core) + */ public Event(String category, String action) { this.category = category; this.action = action; @@ -180,10 +297,22 @@ public class UserLogger { } + /** + * Gets the category + * @return category + * + * @author Ho Namkoong {@literal } (S-Core) + */ public String getCategory() { return category; } + /** + * Gets the action + * @return action + * + * @author Ho Namkoong {@literal } (S-Core) + */ public String getAction() { return action; } @@ -194,17 +323,31 @@ public class UserLogger { } } + /** + * Page information + * + * @author Ho Namkoong {@literal } (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; }