Repository: flex-falcon Updated Branches: refs/heads/feature-autobuild/cleanup [created] 87ad72a6d
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/pom.xml ---------------------------------------------------------------------- diff --git a/compiler/pom.xml b/compiler/pom.xml index 985622e..c34c7e0 100644 --- a/compiler/pom.xml +++ b/compiler/pom.xml @@ -410,6 +410,16 @@ <artifactId>lzma-sdk-4j</artifactId> <version>9.22.0</version> </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.7</version> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.7</version> + </dependency> <dependency> <groupId>org.apache.flex.flexjs.compiler</groupId> http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java b/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java index f8c9cd4..4b88b4f 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java +++ b/compiler/src/main/java/org/apache/flex/compiler/clients/ASC.java @@ -103,6 +103,8 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.google.common.collect.Sets.SetView; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * ActionScript Compiler command-line interface. @@ -115,6 +117,8 @@ import com.google.common.collect.Sets.SetView; public class ASC { + private static final Logger logger = LogManager.getLogger(ASC.class); + private static final String DOUBLE_QUOTE = "\""; /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/clients/ASDOC.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/ASDOC.java b/compiler/src/main/java/org/apache/flex/compiler/clients/ASDOC.java index dadfbf7..861f979 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/clients/ASDOC.java +++ b/compiler/src/main/java/org/apache/flex/compiler/clients/ASDOC.java @@ -46,6 +46,8 @@ import org.apache.flex.swc.io.SWCWriter; import org.apache.flex.swf.io.SizeReportWritingSWFWriter; import org.apache.flex.tools.FlexTool; import org.apache.flex.utils.FilenameNormalization; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Documentation compiler entry point. @@ -55,6 +57,9 @@ import org.apache.flex.utils.FilenameNormalization; */ public class ASDOC extends MXMLC implements FlexTool { + + private static final Logger logger = LogManager.getLogger(ASDOC.class); + /** * Entry point for <code>compc</code> tool. * @@ -205,8 +210,9 @@ public class ASDOC extends MXMLC implements FlexTool @Override protected void reportTargetCompletion() { - if (asdocOutputMessage != null) - println(asdocOutputMessage); + if (asdocOutputMessage != null) { + logger.info(asdocOutputMessage); + } } /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java b/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java index 547f40f..857f3fc 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java +++ b/compiler/src/main/java/org/apache/flex/compiler/clients/COMPC.java @@ -45,6 +45,8 @@ import org.apache.flex.swc.io.SWCWriter; import org.apache.flex.swf.io.SizeReportWritingSWFWriter; import org.apache.flex.tools.FlexTool; import org.apache.flex.utils.FilenameNormalization; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Component compiler entry point. @@ -54,6 +56,9 @@ import org.apache.flex.utils.FilenameNormalization; */ public class COMPC extends MXMLC implements FlexTool { + + private static final Logger logger = LogManager.getLogger(COMPC.class); + /** * Entry point for <code>compc</code> tool. * @@ -199,8 +204,9 @@ public class COMPC extends MXMLC implements FlexTool @Override protected void reportTargetCompletion() { - if (swcOutputMessage != null) - println(swcOutputMessage); + if (swcOutputMessage != null) { + logger.info(swcOutputMessage); + } } /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java b/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java index 7a7bfdd..858e8c7 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java +++ b/compiler/src/main/java/org/apache/flex/compiler/clients/MXMLC.java @@ -98,12 +98,16 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * The entry-point class for mxmlc. */ public class MXMLC implements FlexTool { + private static final Logger logger = LogManager.getLogger(MXMLC.class); + static final String NEWLINE = System.getProperty("line.separator"); private static final String SWF_EXT = ".swf"; private static final String DEFAULT_VAR = "file-specs"; @@ -353,34 +357,35 @@ public class MXMLC implements FlexTool int errorCount = errors.size(); int warningCount = warnings.size(); - if (warningCount > 0) - { - System.err.println(Messages.getString("MXMLC.WarningsHeader")); + if (warningCount > 0) { + logger.error(Messages.getString("MXMLC.WarningsHeader")); printer.printProblems(warnings); } - if (errorCount > 0) - { - System.err.println(Messages.getString("MXMLC.ErrorsHeader")); + if (errorCount > 0) { + logger.error(Messages.getString("MXMLC.ErrorsHeader")); printer.printProblems(errors); } // Output summary of errors and warnings - if (errorCount == 1) - System.err.println(Messages.getString("MXMLC.1_error")); - else if (errorCount > 0) - System.err.println(Messages.getString("MXMLC.multiple_errors_format", - Collections.<String,Object>singletonMap("errorCount", errors.size()))); - - if (warningCount == 1) - System.err.println(Messages.getString("MXMLC.1_warning")); - else if (warningCount > 0) - System.err.println(Messages.getString("MXMLC.multiple_warnings_format", - Collections.<String,Object>singletonMap("warningCount", warnings.size()))); - - if (errorCount > 0) + if (errorCount == 1) { + logger.error(Messages.getString("MXMLC.1_error")); + } else if (errorCount > 0) { + logger.error(Messages.getString("MXMLC.multiple_errors_format", + Collections.<String, Object>singletonMap("errorCount", errors.size()))); + } + + if (warningCount == 1) { + logger.error(Messages.getString("MXMLC.1_warning")); + } else if (warningCount > 0) { + logger.error(Messages.getString("MXMLC.multiple_warnings_format", + Collections.<String, Object>singletonMap("warningCount", warnings.size()))); + } + + if (errorCount > 0) { exitCode = ExitCode.FAILED_WITH_ERRORS; + } } return exitCode; @@ -409,16 +414,6 @@ public class MXMLC implements FlexTool private String swfOutputMessage; /** - * Print a message. - * - * @param msg Message text. - */ - public void println(final String msg) - { - System.out.println(msg); - } - - /** * Wait till the workspace to finish compilation and close. */ protected void waitAndClose() @@ -474,9 +469,10 @@ public class MXMLC implements FlexTool DEFAULT_VAR, LocalizationManager.get(), L10N_CONFIG_PREFIX); - println(getStartMessage()); - if (usage != null) - println(usage); + logger.info(getStartMessage()); + if (usage != null) { + logger.info(usage); + } // Create a default configuration so we can exit gracefully. config = new Configuration(); @@ -506,7 +502,7 @@ public class MXMLC implements FlexTool // Print version if "-version" is present. if (configBuffer.getVar("version") != null) { - println(VersionInfo.buildMessage()); + logger.info(VersionInfo.buildMessage()); return false; } @@ -520,19 +516,19 @@ public class MXMLC implements FlexTool for (String fileName : projectConfigurator.getLoadedConfigurationFiles()) { - println(Messages.getString("MXMLC.Loading_configuration_format", + logger.info(Messages.getString("MXMLC.Loading_configuration_format", Collections.<String,Object>singletonMap("configurationName", fileName))); } // Add a blank line between the configuration list and the rest of // the output to make the start of the output easier to detect. - println(""); + logger.info(""); if (config.isVerbose()) { for (final IFileSpecification themeFile : project.getThemeFiles()) { - println(Messages.getString("MXMLC.Found_theme_file_format", + logger.info(Messages.getString("MXMLC.Found_theme_file_format", Collections.<String, Object>singletonMap("themePath", themeFile.getPath()))); } @@ -690,7 +686,7 @@ public class MXMLC implements FlexTool if (swfOutputMessage != null) { reportRequiredRSLs(target); - println(swfOutputMessage); + logger.info(swfOutputMessage); } } @@ -733,7 +729,7 @@ public class MXMLC implements FlexTool } } - println(Joiner.on("\n\n").join(astDump)); + logger.info(Joiner.on("\n\n").join(astDump)); } /** @@ -784,8 +780,8 @@ public class MXMLC implements FlexTool if (requiredRSLs.isEmpty() && legacyRSLs.isEmpty()) return; - - println(Messages.getString("MXMLC.Required_RSLs")); + + logger.info(Messages.getString("MXMLC.Required_RSLs")); // loop thru the RSLs and print out the required RSLs. for (RSLSettings rslSettings : requiredRSLs) @@ -800,16 +796,16 @@ public class MXMLC implements FlexTool assert false; // One RSL URL is required. break; case 1: - println(Messages.getString("MXMLC.required_rsl_url_format", + logger.info(Messages.getString("MXMLC.required_rsl_url_format", params)); break; case 2: - println(Messages.getString("MXMLC.required_rsl_url_with_1_failover_format", + logger.info(Messages.getString("MXMLC.required_rsl_url_with_1_failover_format", params)); break; default: params.put("failoverCount", rslURLs.size() - 1); - println(Messages.getString("MXMLC.required_rsl_url_with_multiple_failovers_format", + logger.info(Messages.getString("MXMLC.required_rsl_url_with_multiple_failovers_format", params)); break; } @@ -818,7 +814,7 @@ public class MXMLC implements FlexTool // All -runtime-shared-libraries are required for (String rslURL : legacyRSLs) - println(Messages.getString("MXMLC.required_rsl_url_format", + logger.info(Messages.getString("MXMLC.required_rsl_url_format", Collections.<String,Object>singletonMap("rslPath", rslURL))); } } @@ -980,7 +976,7 @@ public class MXMLC implements FlexTool private void verboseMessage(String s) { if (config.isVerbose()) - println(s); + logger.info(s); } /** @@ -1074,8 +1070,8 @@ public class MXMLC implements FlexTool keywords, LocalizationManager.get(), L10N_CONFIG_PREFIX); - println(getStartMessage()); - println(usages); + logger.info(getStartMessage()); + logger.info(usages); } /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/clients/Optimizer.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/clients/Optimizer.java b/compiler/src/main/java/org/apache/flex/compiler/clients/Optimizer.java index fa62e0a..220e937 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/clients/Optimizer.java +++ b/compiler/src/main/java/org/apache/flex/compiler/clients/Optimizer.java @@ -70,6 +70,8 @@ import java.util.Set; import org.apache.commons.io.IOUtils; import org.apache.flex.tools.FlexTool; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Command line optimizer - can read in a swf, apply the optimizations usually done during swf linking, @@ -77,6 +79,8 @@ import org.apache.flex.tools.FlexTool; */ public class Optimizer implements FlexTool { + private static final Logger logger = LogManager.getLogger(Optimizer.class); + static final String NEWLINE = System.getProperty("line.separator"); private static final String DEFAULT_VAR = "input"; private static final String L10N_CONFIG_PREFIX = "org.apache.flex.compiler.internal.config.configuration"; @@ -160,7 +164,7 @@ public class Optimizer implements FlexTool params.put("byteCount", swfSize); params.put("path", outputFile.getCanonicalPath()); params.put("seconds", seconds); - System.out.println(Messages.getString( + logger.info(Messages.getString( "MXMLC.bytes_written_to_file_in_seconds_format", params)); } @@ -234,9 +238,10 @@ public class Optimizer implements FlexTool DEFAULT_VAR, LocalizationManager.get(), L10N_CONFIG_PREFIX); - System.out.println(getStartMessage()); - if (usage != null) - System.out.println(usage); + logger.info(getStartMessage()); + if (usage != null) { + logger.info(usage); + } // Create a default configuration so we can exit gracefully. config = new OptimizerConfiguration(); @@ -257,7 +262,7 @@ public class Optimizer implements FlexTool // Print version if "-version" is present. if (configBuffer.getVar("version") != null) { - System.out.println(VersionInfo.buildMessage()); + logger.info(VersionInfo.buildMessage()); return false; } @@ -310,8 +315,8 @@ public class Optimizer implements FlexTool keywords, LocalizationManager.get(), L10N_CONFIG_PREFIX); - System.out.println(getStartMessage()); - System.out.println(usages); + logger.info(getStartMessage()); + logger.info(usages); } /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/config/Configurator.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/config/Configurator.java b/compiler/src/main/java/org/apache/flex/compiler/config/Configurator.java index 55d23ff..eb8b870 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/config/Configurator.java +++ b/compiler/src/main/java/org/apache/flex/compiler/config/Configurator.java @@ -58,6 +58,8 @@ import org.apache.flex.utils.Trace; import com.google.common.base.Function; import com.google.common.collect.Lists; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * A class that allows a client change compiler settings and to @@ -66,6 +68,8 @@ import com.google.common.collect.Lists; public class Configurator implements ICompilerSettings, IConfigurator, ICompilerSettingsConstants, Cloneable { + private static final Logger logger = LogManager.getLogger(Configurator.class); + /** * Marker class for RSLSettings because RSLSettings need special handling * in getOptions(). @@ -1378,7 +1382,7 @@ public class Configurator implements ICompilerSettings, IConfigurator, ICompiler } else { - // System.err.println("unprocessed compiler options: " + key + EQUALS_STRING + value); + logger.warn("unprocessed compiler options: " + key + EQUALS_STRING + value); } } @@ -1425,7 +1429,7 @@ public class Configurator implements ICompilerSettings, IConfigurator, ICompiler } else { - // System.err.println("unprocessed compiler options: " + key + EQUALS_STRING + value); + logger.warn("unprocessed compiler options: " + key + EQUALS_STRING + value); } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/as/codegen/DumpBURMState.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/as/codegen/DumpBURMState.java b/compiler/src/main/java/org/apache/flex/compiler/internal/as/codegen/DumpBURMState.java index e1a5f28..3b0923e 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/as/codegen/DumpBURMState.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/as/codegen/DumpBURMState.java @@ -22,14 +22,20 @@ package org.apache.flex.compiler.internal.as.codegen; import java.io.File; import java.util.Date; +import org.apache.flex.compiler.clients.Optimizer; import org.apache.flex.compiler.internal.testing.NodesToXMLStringFormatter; import org.apache.flex.compiler.tree.as.IASNode; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Class containing debug code that dumps BURM state to an XML file. */ final class DumpBURMState { + + private static final Logger logger = LogManager.getLogger(DumpBURMState.class); + static void dump(CmcEmitter burm, IASNode n) { // un-comment the following line to enable dumping of BURM errors. @@ -65,10 +71,10 @@ final class DumpBURMState } catch (Exception e) { - System.err.println("Unable to dump due to: " + e.toString()); + logger.error("Unable to dump due to: " + e.toString()); try { - System.err.println(new NodesToXMLStringFormatter(n).toString()); + logger.error(new NodesToXMLStringFormatter(n).toString()); } catch ( Exception cantformat) { http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingCodeGenUtils.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingCodeGenUtils.java b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingCodeGenUtils.java index 296a81b..4d6d948 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingCodeGenUtils.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingCodeGenUtils.java @@ -22,6 +22,7 @@ package org.apache.flex.compiler.internal.codegen.databinding; import static org.apache.flex.abc.ABCConstants.*; +import java.security.acl.LastOwnerException; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -34,6 +35,7 @@ import org.apache.flex.abc.semantics.Name; import org.apache.flex.abc.semantics.Namespace; import org.apache.flex.abc.semantics.Nsset; import org.apache.flex.abc.visitors.IABCVisitor; +import org.apache.flex.compiler.clients.Optimizer; import org.apache.flex.compiler.constants.IASLanguageConstants; import org.apache.flex.compiler.definitions.INamespaceDefinition; import org.apache.flex.compiler.internal.abc.FunctionGeneratorHelper; @@ -46,6 +48,8 @@ import org.apache.flex.compiler.internal.tree.as.LiteralNode; import org.apache.flex.compiler.mxml.IMXMLTypeConstants; import org.apache.flex.compiler.projects.ICompilerProject; import org.apache.flex.compiler.tree.as.IExpressionNode; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * A bunch of static, low level helpers for generating instruction lists @@ -60,6 +64,7 @@ import org.apache.flex.compiler.tree.as.IExpressionNode; */ public class BindingCodeGenUtils { + private static final Logger logger = LogManager.getLogger(BindingCodeGenUtils.class); private static final Name NAME_VOID = new Name(IASLanguageConstants.void_); @@ -535,7 +540,7 @@ public class BindingCodeGenUtils insns.addInstruction(OP_dup); if (!useSocketForTrace) { - System.out.println("** Warning: diagnostic trace not using socket. Will be invisible when running most unit tests"); + logger.info("** Warning: diagnostic trace not using socket. Will be invisible when running most unit tests"); insns.addInstruction(OP_findpropstrict, new Object[] { new Name("trace") } ); insns.addInstruction(OP_swap); insns.addInstruction(OP_callpropvoid, new Object[] { new Name("trace"), 1 } ); @@ -714,7 +719,7 @@ public class BindingCodeGenUtils { if (doLog) { - System.out.println("MXMLBindingDirHelp: " + s); + logger.info("MXMLBindingDirHelp: " + s); } } @@ -724,7 +729,7 @@ public class BindingCodeGenUtils assert s != null; if (doLog) { - System.out.println("MXMLBindingDirHelp: " + s); + logger.info("MXMLBindingDirHelp: " + s); insns.addInstruction(OP_debugfile, s); } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java index 330b159..2ca72f9 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/BindingInfo.java @@ -57,6 +57,8 @@ import org.apache.flex.compiler.tree.mxml.IMXMLExpressionNode; import org.apache.flex.compiler.tree.mxml.IMXMLInstanceNode; import org.apache.flex.compiler.tree.mxml.IMXMLModelPropertyNode; import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * data that describes a single databinding expression. @@ -64,6 +66,9 @@ import org.apache.flex.compiler.tree.mxml.IMXMLPropertySpecifierNode; */ public class BindingInfo implements Comparable<BindingInfo> { + + private static final Logger logger = LogManager.getLogger(BindingInfo.class); + /** * This form of the constructor is used for the "normal" case, * like <s:Button label="{foo}"/> @@ -310,7 +315,7 @@ public class BindingInfo implements Comparable<BindingInfo> { // there will be (presumably) some cases where we can't make a destination string. // For now, however, any case where we fail to do so is probably a bug - System.err.println("findDestinationString can't parse parent: " + parent); + logger.error("findDestinationString can't parse parent: " + parent); } return destString; } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java index 2551260..7536461 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java @@ -52,6 +52,8 @@ import org.apache.flex.compiler.tree.as.IExpressionNode; import org.apache.flex.compiler.tree.mxml.IMXMLBindingNode; import org.apache.flex.compiler.tree.mxml.IMXMLDataBindingNode; import org.apache.flex.compiler.workspaces.IWorkspace; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Keeps track of all the Data Bindings in an MXML file and helps with codegen @@ -78,6 +80,8 @@ import org.apache.flex.compiler.workspaces.IWorkspace; */ public class MXMLBindingDirectiveHelper { + private static final Logger logger = LogManager.getLogger(MXMLBindingDirectiveHelper.class); + // Some AET names we use locally private static final Name NAME_OBJTYPE = new Name(IASLanguageConstants.Object); private static final Name NAME_ARRAYTYPE = new Name(IASLanguageConstants.Array); @@ -355,49 +359,49 @@ public class MXMLBindingDirectiveHelper private String getSourceStringFromMemberAccessExpressionNode(MemberAccessExpressionNode node) { String s = ""; - + IExpressionNode left = node.getLeftOperandNode(); - if (left instanceof FunctionCallNode) // probably a cast - { + if (left instanceof FunctionCallNode) { IASNode child = ((FunctionCallNode)left).getArgumentsNode().getChild(0); - if (child instanceof IdentifierNode) - s = getSourceStringFromIdentifierNode((IdentifierNode)child); - else if (child instanceof MemberAccessExpressionNode) - s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)child); - } - else if (left instanceof MemberAccessExpressionNode) - s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)left); - else if (left instanceof IdentifierNode) - s = getSourceStringFromIdentifierNode((IdentifierNode)left); - else if (left instanceof BinaryOperatorAsNode) - { + if (child instanceof IdentifierNode) { + s = getSourceStringFromIdentifierNode((IdentifierNode) child); + } else if (child instanceof MemberAccessExpressionNode) { + s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode) child); + } + } else if (left instanceof MemberAccessExpressionNode) { + s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode) left); + } else if (left instanceof IdentifierNode) { + s = getSourceStringFromIdentifierNode((IdentifierNode) left); + } else if (left instanceof BinaryOperatorAsNode) { left = (IExpressionNode)((BinaryOperatorAsNode)left).getChild(0); - if (left instanceof MemberAccessExpressionNode) - s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)left); - else if (left instanceof IdentifierNode) - s = getSourceStringFromIdentifierNode((IdentifierNode)left); - else - System.out.println("expected binding BinaryOperatorAsNode left node" + node.toString()); + if (left instanceof MemberAccessExpressionNode) { + s = getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode) left); + } else if (left instanceof IdentifierNode) { + s = getSourceStringFromIdentifierNode((IdentifierNode) left); + } else { + logger.info("expected binding BinaryOperatorAsNode left node" + node.toString()); + } + } else { + logger.info("expected binding member access left node" + node.toString()); } - else - System.out.println("expected binding member access left node" + node.toString()); s += "."; IExpressionNode right = node.getRightOperandNode(); if (right instanceof FunctionCallNode) // probably a cast { IASNode child = ((FunctionCallNode)right).getArgumentsNode().getChild(0); - if (child instanceof IdentifierNode) - s += getSourceStringFromIdentifierNode((IdentifierNode)child); - else if (child instanceof MemberAccessExpressionNode) - s += getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)child); - } - else if (right instanceof MemberAccessExpressionNode) - s += getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)right); - else if (right instanceof IdentifierNode) - s += getSourceStringFromIdentifierNode((IdentifierNode)right); - else - System.out.println("expected binding member access right node" + node.toString()); + if (child instanceof IdentifierNode) { + s += getSourceStringFromIdentifierNode((IdentifierNode) child); + } else if (child instanceof MemberAccessExpressionNode) { + s += getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode) child); + } + } else if (right instanceof MemberAccessExpressionNode) { + s += getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode) right); + } else if (right instanceof IdentifierNode) { + s += getSourceStringFromIdentifierNode((IdentifierNode) right); + } else { + logger.info("expected binding member access right node" + node.toString()); + } return s; } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/WatcherAnalyzer.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/WatcherAnalyzer.java b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/WatcherAnalyzer.java index 8dcdf8e..e400a2c 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/WatcherAnalyzer.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/codegen/databinding/WatcherAnalyzer.java @@ -43,6 +43,8 @@ import org.apache.flex.compiler.tree.as.IExpressionNode; import org.apache.flex.compiler.tree.as.IFunctionCallNode; import org.apache.flex.compiler.tree.as.IIdentifierNode; import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** @@ -51,6 +53,9 @@ import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode; */ public class WatcherAnalyzer { + + private static final Logger logger = LogManager.getLogger(WatcherAnalyzer.class); + /** * Constructor * @@ -325,7 +330,7 @@ public class WatcherAnalyzer type = determineWatcherType(def); // figure out what kind of watcher to make if (type == WatcherType.ERROR) { - System.err.println("can't get watcher for " + def); + logger.error("can't get watcher for " + def); return; // This should never happen. If it does, there is presumably a bug. // But - better to recover here, than to go on and NPE. // This is a workaround for CMP-1283 http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/common/Counter.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/common/Counter.java b/compiler/src/main/java/org/apache/flex/compiler/internal/common/Counter.java index e24eb2e..b61cc7b 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/common/Counter.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/common/Counter.java @@ -19,6 +19,10 @@ package org.apache.flex.compiler.internal.common; +import org.apache.flex.compiler.internal.codegen.databinding.MXMLBindingDirectiveHelper; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -33,6 +37,9 @@ import java.util.Map; */ public class Counter { + + private static final Logger logger = LogManager.getLogger(Counter.class); + /** * Flag that enables counting of instances of TokenBase. */ @@ -132,7 +139,7 @@ public class Counter for (String key : keys) { - System.out.println(getCount(key) + "\t" + key); + logger.info(getCount(key) + "\t" + key); } } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/config/FileConfigurator.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/config/FileConfigurator.java b/compiler/src/main/java/org/apache/flex/compiler/internal/config/FileConfigurator.java index 89e015f..a8eddd3 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/config/FileConfigurator.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/config/FileConfigurator.java @@ -33,6 +33,9 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.apache.commons.io.IOUtils; +import org.apache.flex.compiler.internal.codegen.databinding.WatcherAnalyzer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.Locator; @@ -58,6 +61,8 @@ import com.google.common.collect.ImmutableSet; public class FileConfigurator { + private static final Logger logger = LogManager.getLogger(FileConfigurator.class); + public static class SAXConfigurationException extends SAXParseException { private static final long serialVersionUID = -3388781933743434302L; @@ -240,7 +245,7 @@ public class FileConfigurator contextStack.push(newctx); return; } - System.err.println("Unknown tag:" + fullname); + logger.error("Unknown tag:" + fullname); throw new SAXConfigurationException( new ConfigurationException.UnknownVariable( fullname, source, locator.getLineNumber()), http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/config/FlashBuilderConfigurator.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/config/FlashBuilderConfigurator.java b/compiler/src/main/java/org/apache/flex/compiler/internal/config/FlashBuilderConfigurator.java index 23c7a45..1aa8806 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/config/FlashBuilderConfigurator.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/config/FlashBuilderConfigurator.java @@ -28,6 +28,9 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.apache.commons.io.IOUtils; +import org.apache.flex.compiler.internal.common.Counter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.Locator; @@ -48,6 +51,8 @@ import org.apache.flex.compiler.filespecs.FileSpecification; public class FlashBuilderConfigurator { + private static final Logger logger = LogManager.getLogger(FlashBuilderConfigurator.class); + public static class SAXConfigurationException extends SAXParseException { private static final long serialVersionUID = -3388781933743434302L; @@ -137,11 +142,12 @@ public class FlashBuilderConfigurator // add new last arg which is path to app fbArgs.add(aspr.applicationPath); } - - System.out.println("using FlashBuilder Project Files"); - System.out.println("FlashBuilder settings:"); - for (String arg : fbArgs) - System.out.println(" " + arg); + + logger.info("using FlashBuilder Project Files"); + logger.info("FlashBuilder settings:"); + for (String arg : fbArgs) { + logger.info(" " + arg); + } return fbArgs.toArray(new String[fbArgs.size()]); } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/fxg/logging/SystemLogger.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/fxg/logging/SystemLogger.java b/compiler/src/main/java/org/apache/flex/compiler/internal/fxg/logging/SystemLogger.java index 09b9201..d60229c 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/fxg/logging/SystemLogger.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/fxg/logging/SystemLogger.java @@ -22,6 +22,8 @@ package org.apache.flex.compiler.internal.fxg.logging; import java.io.PrintStream; import org.apache.commons.io.IOUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** @@ -29,6 +31,9 @@ import org.apache.commons.io.IOUtils; */ public class SystemLogger extends AbstractLogger { + + private static final Logger logger = LogManager.getLogger(SystemLogger.class); + public SystemLogger() { super(NONE); @@ -40,6 +45,7 @@ public class SystemLogger extends AbstractLogger if (level < getLevel()) return; + // TODO: Refactor this ... PrintStream ps = level > INFO ? System.err : System.out; try http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLData.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLData.java b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLData.java index ac2adc2..459eeb5 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLData.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLData.java @@ -36,6 +36,7 @@ import org.apache.flex.compiler.common.MutablePrefixMap; import org.apache.flex.compiler.common.PrefixMap; import org.apache.flex.compiler.filespecs.FileSpecification; import org.apache.flex.compiler.filespecs.IFileSpecification; +import org.apache.flex.compiler.internal.fxg.logging.SystemLogger; import org.apache.flex.compiler.internal.parsing.mxml.BalancingMXMLProcessor; import org.apache.flex.compiler.internal.parsing.mxml.MXMLToken; import org.apache.flex.compiler.internal.parsing.mxml.MXMLTokenizer; @@ -49,6 +50,8 @@ import org.apache.flex.compiler.problems.ICompilerProblem; import org.apache.flex.compiler.problems.SyntaxProblem; import org.apache.flex.utils.FastStack; import org.apache.flex.utils.FastStack.IFastStackDecorator; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Encapsulation of an MXML file, with individual units for each open tag, close @@ -57,6 +60,8 @@ import org.apache.flex.utils.FastStack.IFastStackDecorator; public class MXMLData implements IMXMLData { + private static final Logger logger = LogManager.getLogger(MXMLData.class); + private final class TokenizerPayload { private List<MXMLToken> tokens; @@ -906,7 +911,7 @@ public class MXMLData implements IMXMLData { for (IMXMLUnitData unit : getUnits()) { - System.out.println(((MXMLUnitData)unit).toDumpString()); + logger.info(((MXMLUnitData)unit).toDumpString()); } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java index 13833be..1f1c4c7 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/mxml/MXMLManifestManager.java @@ -32,6 +32,8 @@ import java.util.TreeSet; import javax.xml.parsers.DocumentBuilderFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -57,6 +59,9 @@ import com.google.common.collect.SetMultimap; */ public class MXMLManifestManager implements IMXMLManifestManager { + + private static final Logger logger = LogManager.getLogger(MXMLManifestManager.class); + /** * Helper method to get the class name from the * class info. Takes are of checking if the class @@ -266,9 +271,9 @@ public class MXMLManifestManager implements IMXMLManifestManager } } } + } else { + logger.info("Unable to parse " + manifestFileName); } - else - System.out.println("Unable to parse " + manifestFileName); } /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java b/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java index 51718ca..623eff9 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/parsing/mxml/MXMLTokenizer.java @@ -40,6 +40,8 @@ import org.apache.flex.compiler.parsing.MXMLTokenTypes; import org.apache.flex.compiler.problems.ICompilerProblem; import org.apache.flex.compiler.problems.InternalCompilerProblem2; import org.apache.flex.utils.NonLockingStringReader; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Tokenizes MXML files. Uses RawTagTokenizer to get basic tokens. Ignores comments (<!--...-->), @@ -48,6 +50,9 @@ import org.apache.flex.utils.NonLockingStringReader; */ public class MXMLTokenizer implements IMXMLTokenizer, Closeable { + + private static final Logger logger = LogManager.getLogger(MXMLTokenizer.class); + /** * Start offset (for when you're parsing a section of the document that * doesn't start at the beginning) @@ -419,7 +424,7 @@ public class MXMLTokenizer implements IMXMLTokenizer, Closeable List<MXMLToken> tokens = tokenizer.parseTokens(fileSpec.createReader()); for (MXMLToken token : tokens) { - System.out.println(token.toDumpString()); + logger.info(token.toDumpString()); } } catch (FileNotFoundException e) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/targets/SWFTarget.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/SWFTarget.java b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/SWFTarget.java index 59afb54..c738d02 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/SWFTarget.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/SWFTarget.java @@ -49,7 +49,6 @@ import org.apache.flex.compiler.definitions.IDefinition; import org.apache.flex.compiler.definitions.references.IResolvedQualifiersReference; import org.apache.flex.compiler.definitions.references.ReferenceFactory; import org.apache.flex.compiler.exceptions.BuildCanceledException; -import org.apache.flex.compiler.internal.caches.SWFCache; import org.apache.flex.compiler.internal.definitions.ClassDefinition; import org.apache.flex.compiler.internal.projects.CompilerProject; import org.apache.flex.compiler.internal.projects.FlexProject; @@ -82,6 +81,8 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Sets; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Concrete implementation of ITarget for building a collection of source files @@ -89,6 +90,9 @@ import com.google.common.collect.Sets; */ public abstract class SWFTarget extends Target implements ISWFTarget { + + private static final Logger logger = LogManager.getLogger(SWFTarget.class); + protected static final class SWFFrameInfo { public static final boolean EXTERNS_ALLOWED = true; @@ -427,7 +431,7 @@ public abstract class SWFTarget extends Target implements ISWFTarget Collection<EmitterClassVisitor> classes = emitter.getDefinedClasses(); for (EmitterClassVisitor clazz : classes) { - System.out.println("scanning for overrides: " + clazz.getInstanceInfo().name.getBaseName()); + logger.info("scanning for overrides: " + clazz.getInstanceInfo().name.getBaseName()); Iterator<Trait> instanceTraits = clazz.instanceTraits.iterator(); while (instanceTraits.hasNext()) { http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassDefinitionNode.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassDefinitionNode.java b/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassDefinitionNode.java index 8f73fc5..4e05858 100644 --- a/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassDefinitionNode.java +++ b/compiler/src/main/java/org/apache/flex/compiler/internal/tree/mxml/MXMLClassDefinitionNode.java @@ -42,6 +42,7 @@ import org.apache.flex.compiler.internal.mxml.StateGroupDefinition; import org.apache.flex.compiler.internal.projects.FlexProject; import org.apache.flex.compiler.internal.scopes.MXMLFileScope; import org.apache.flex.compiler.internal.scopes.TypeScope; +import org.apache.flex.compiler.internal.targets.SWFTarget; import org.apache.flex.compiler.internal.tree.as.ImportNode; import org.apache.flex.compiler.internal.tree.as.NodeBase; import org.apache.flex.compiler.mxml.IMXMLTagAttributeData; @@ -70,6 +71,8 @@ import org.apache.flex.compiler.tree.mxml.IMXMLSpecifierNode; import org.apache.flex.compiler.tree.mxml.IMXMLStateNode; import org.apache.flex.compiler.tree.mxml.IMXMLStyleSpecifierNode; import com.google.common.collect.ArrayListMultimap; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import static org.apache.flex.compiler.mxml.IMXMLLanguageConstants.*; @@ -82,6 +85,8 @@ public class MXMLClassDefinitionNode extends MXMLClassReferenceNodeBase implements IMXMLClassDefinitionNode, IScopedNode { + private static final Logger logger = LogManager.getLogger(MXMLClassDefinitionNode.class); + /** * Constructor * @@ -1027,13 +1032,13 @@ public class MXMLClassDefinitionNode extends MXMLClassReferenceNodeBase for (String state : states) { - System.out.println("State " + state); + logger.info("State " + state); List<IMXMLNode> nodes = getNodesDependentOnState(state); if (nodes != null) { for (IMXMLNode node : nodes) { - System.out.println(" " + node); + logger.info(" " + node); } } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/swc/SWCDepends.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/swc/SWCDepends.java b/compiler/src/main/java/org/apache/flex/swc/SWCDepends.java index 2d240a0..f5575ef 100644 --- a/compiler/src/main/java/org/apache/flex/swc/SWCDepends.java +++ b/compiler/src/main/java/org/apache/flex/swc/SWCDepends.java @@ -70,6 +70,8 @@ import org.apache.flex.compiler.problems.InternalCompilerProblem; import org.apache.flex.compiler.targets.ITargetSettings; import org.apache.flex.compiler.units.ICompilationUnit; import org.apache.flex.swc.catalog.XMLFormatter; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * swcdepends command line utility. @@ -85,6 +87,8 @@ import org.apache.flex.swc.catalog.XMLFormatter; public class SWCDepends { + private static final Logger logger = LogManager.getLogger(SWCDepends.class); + // XML names public static final String SWC_DEPENDENCY_ORDER_ELEMENT = "swc-dependency-order"; public static final String SWC_DEPENDENCIES_ELEMENT = "swc-dependencies"; @@ -326,21 +330,21 @@ public class SWCDepends if (config.getShowTypes()) { - System.out.print("\t\t" + entry.getKey() + "\t"); + logger.info("\t\t" + entry.getKey() + "\t"); StringBuilder sb = new StringBuilder(); for (Iterator<DependencyType>iter = entry.getValue().iterator(); iter.hasNext();) { DependencyType type = iter.next(); - - System.out.print(type.getSymbol()); + + logger.info(type.getSymbol()); sb.append(type.getSymbol()); if (iter.hasNext()) { sb.append(","); - System.out.print(" "); + logger.info(" "); } } @@ -511,7 +515,7 @@ public class SWCDepends */ protected void println(final String msg) { - System.out.println(msg); + logger.info(msg); } /** http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/swf/io/SWFDump.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/swf/io/SWFDump.java b/compiler/src/main/java/org/apache/flex/swf/io/SWFDump.java index 78bee7c..a7f449d 100644 --- a/compiler/src/main/java/org/apache/flex/swf/io/SWFDump.java +++ b/compiler/src/main/java/org/apache/flex/swf/io/SWFDump.java @@ -52,6 +52,7 @@ import org.apache.flex.compiler.clients.problems.WorkspaceProblemFormatter; import org.apache.flex.compiler.common.VersionInfo; import org.apache.flex.compiler.internal.workspaces.Workspace; import org.apache.flex.compiler.problems.ICompilerProblem; +import org.apache.flex.swc.SWCDepends; import org.apache.flex.swf.Header; import org.apache.flex.swf.SWF; import org.apache.flex.swf.SWFFrame; @@ -91,12 +92,17 @@ import org.apache.flex.utils.Base64; import org.apache.flex.utils.Trace; import com.google.common.collect.ImmutableList; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; /** * Dump a SWF model to XML. Usage: swfdump [-abc] file1.swf */ public final class SWFDump { + + private static final Logger logger = LogManager.getLogger(SWFDump.class); + /** * Dump a SWF at a given URL. * @@ -2385,15 +2391,15 @@ public final class SWFDump public static void main(String[] args) throws IOException { // This message should not be localized. - System.err.println("Apache Flex SWF Dump Utility"); - System.err.println(VersionInfo.buildMessage()); - System.err.println(""); + logger.error("Apache Flex SWF Dump Utility"); + logger.error(VersionInfo.buildMessage()); + logger.error(""); if (args.length == 0) { // TODO: decide which options to implement. // System.err.println("Usage: swfdump [-encode] [-asm] [-abc] [-showbytecode] [-showdebugsource] [-showoffset] [-noglyphs] [-save file.swf] [-nofunctions] [-out file.swfx] file1.swf ..."); - System.err.println("Usage: swfdump [-abc] file1.swf"); + logger.error("Usage: swfdump [-abc] file1.swf"); System.exit(1); } @@ -2501,13 +2507,15 @@ public final class SWFDump } else { - System.err.println("unknown argument " + args[index]); + logger.error("unknown argument " + args[index]); ++index; } } - if (out == null) + if (out == null) { + // TODO: Refactor this ... out = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"), true); + } File f = new File(args[index]); URL[] urls = new URL[0]; @@ -2607,13 +2615,13 @@ public final class SWFDump if (Trace.error) e.printStackTrace(); - System.err.println(""); - System.err.println("An unrecoverable error occurred. The given file " + urls[i] + " may not be"); - System.err.println("a valid swf."); + logger.error(""); + logger.error("An unrecoverable error occurred. The given file " + urls[i] + " may not be"); + logger.error("a valid swf."); } catch (FileNotFoundException e) { - System.err.println("Error: " + e.getMessage()); + logger.error("Error: " + e.getMessage()); System.exit(1); } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/utils/Base64.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/utils/Base64.java b/compiler/src/main/java/org/apache/flex/utils/Base64.java index cc4315c..60e1899 100644 --- a/compiler/src/main/java/org/apache/flex/utils/Base64.java +++ b/compiler/src/main/java/org/apache/flex/utils/Base64.java @@ -19,6 +19,10 @@ package org.apache.flex.utils; +import org.apache.flex.swc.SWCDepends; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + /** * Code to read and write Base64-encoded text. Fairly * special-purpose, not quite ready for general streaming as they @@ -27,6 +31,9 @@ package org.apache.flex.utils; */ public class Base64 { + + private static final Logger logger = LogManager.getLogger(Base64.class); + private static final char alphabet[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', @@ -267,13 +274,13 @@ public class Base64 } } } - System.out.println(mesg); + logger.info(mesg); if (printData) { - System.out.println("Decoded: " + new String(raw)); - System.out.println("Encoded: " + encoded); - System.out.println("Decoded: " + new String(check)); + logger.info("Decoded: " + new String(raw)); + logger.info("Encoded: " + encoded); + logger.info("Decoded: " + new String(check)); } /* http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/java/org/apache/flex/utils/Trace.java ---------------------------------------------------------------------- diff --git a/compiler/src/main/java/org/apache/flex/utils/Trace.java b/compiler/src/main/java/org/apache/flex/utils/Trace.java index e8b67a9..424393a 100644 --- a/compiler/src/main/java/org/apache/flex/utils/Trace.java +++ b/compiler/src/main/java/org/apache/flex/utils/Trace.java @@ -19,6 +19,9 @@ package org.apache.flex.utils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import java.util.Date; /** @@ -45,6 +48,9 @@ import java.util.Date; */ public class Trace { + + private static final Logger logger = LogManager.getLogger(Trace.class); + public static final boolean all = (System.getProperty("trace.flex") != null); public static final boolean phase = all || (System.getProperty("trace.phase") != null); @@ -112,26 +118,29 @@ public class Trace * is also shown in the date. */ public static void trace(String str) { - if (timeStamp) - System.err.print(new Date()); - - if (timeStampMs || timeStampMsRel) - { - if (timeStampMsRel && (t0 == 0)) - t0 = System.currentTimeMillis(); + if (timeStamp) { + logger.error(new Date()); + } - System.err.print((System.currentTimeMillis() - t0) + " "); + if (timeStampMs || timeStampMsRel) { + if (timeStampMsRel && (t0 == 0)) { + t0 = System.currentTimeMillis(); + } + + logger.error((System.currentTimeMillis() - t0) + " "); } - if(caller) - System.err.print(ExceptionUtil.getCallAt(new Throwable(), 1) + " "); + if(caller) { + logger.error(ExceptionUtil.getCallAt(new Throwable(), 1) + " "); + } System.err.println(str); - if (stackLines > 0) - System.err.println(ExceptionUtil.getStackTraceLines(new Throwable(), stackLines)); - else if (stackPrefix != null) - System.err.println(ExceptionUtil.getStackTraceUpTo(new Throwable(), stackPrefix)); + if (stackLines > 0) { + logger.error(ExceptionUtil.getStackTraceLines(new Throwable(), stackLines)); + } else if (stackPrefix != null) { + logger.error(ExceptionUtil.getStackTraceUpTo(new Throwable(), stackPrefix)); + } } /** Reset the relative clock to zero * Only has an effect when -Dtrace.timeStampMsRel is enabled http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/main/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/compiler/src/main/resources/log4j2.xml b/compiler/src/main/resources/log4j2.xml new file mode 100644 index 0000000..80ed714 --- /dev/null +++ b/compiler/src/main/resources/log4j2.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<Configuration status="WARN"> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> + </Console> + </Appenders> + <Loggers> + <Root level="error"> + <AppenderRef ref="Console"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/test/java/as/ASFeatureTestsBase.java ---------------------------------------------------------------------- diff --git a/compiler/src/test/java/as/ASFeatureTestsBase.java b/compiler/src/test/java/as/ASFeatureTestsBase.java index 730f45a..ca11b2b 100644 --- a/compiler/src/test/java/as/ASFeatureTestsBase.java +++ b/compiler/src/test/java/as/ASFeatureTestsBase.java @@ -22,6 +22,8 @@ package as; import org.apache.flex.compiler.clients.MXMLC; import org.apache.flex.compiler.problems.ICompilerProblem; import org.apache.flex.utils.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import utils.FlashplayerSecurityHandler; import java.io.BufferedWriter; @@ -45,7 +47,10 @@ import static org.junit.Assert.fail; */ public class ASFeatureTestsBase { - private static final String NAMESPACE_2009 = "http://ns.adobe.com/mxml/2009"; + + private static final Logger logger = LogManager.getLogger(ASFeatureTestsBase.class); + + private static final String NAMESPACE_2009 = "http://ns.adobe.com/mxml/2009"; protected File generateTempFile(String source) { @@ -77,7 +82,7 @@ public class ASFeatureTestsBase protected String compile(File tempASFile, String source, boolean withFramework, boolean withRPC, boolean withSpark, String[] otherOptions, boolean checkExitCode) { - System.out.println("Generating test:"); + logger.info("Generating test:"); ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter(); // Build the list of SWCs to compile against on the library path. @@ -119,7 +124,7 @@ public class ASFeatureTestsBase cmdLine.append(arg).append(" "); } - System.out.println("Compiling test:\n" + cmdLine.toString()); + logger.info("Compiling test:\n" + cmdLine.toString()); int exitCode = mxmlc.mainNoExit(args.toArray(new String[args.size()])); // Check that there were no compilation problems. @@ -131,7 +136,7 @@ public class ASFeatureTestsBase sb.append('\n'); } - System.out.println("After compile:\n" + sb.toString()); + logger.info("After compile:\n" + sb.toString()); if (checkExitCode) assertThat(sb.toString(), exitCode, is(0)); return sb.toString(); @@ -162,7 +167,7 @@ public class ASFeatureTestsBase String[] runArgs = new String[] { testAdapter.getFlashplayerDebugger().getPath(), swf }; try { - System.out.println("Executing test:\n" + Arrays.toString(runArgs)); + logger.info("Executing test:\n" + Arrays.toString(runArgs)); // TODO: Hack to add the directory containing the temp swf to the flashplayer trust. new FlashplayerSecurityHandler().trustFile(tempASFile.getParentFile()); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/test/java/mxml/tags/MXMLFeatureTestsBase.java ---------------------------------------------------------------------- diff --git a/compiler/src/test/java/mxml/tags/MXMLFeatureTestsBase.java b/compiler/src/test/java/mxml/tags/MXMLFeatureTestsBase.java index 9003b09..6bb96db 100644 --- a/compiler/src/test/java/mxml/tags/MXMLFeatureTestsBase.java +++ b/compiler/src/test/java/mxml/tags/MXMLFeatureTestsBase.java @@ -22,6 +22,8 @@ package mxml.tags; import org.apache.flex.compiler.clients.MXMLC; import org.apache.flex.compiler.problems.ICompilerProblem; import org.apache.flex.utils.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.BufferedWriter; import java.io.File; @@ -45,11 +47,14 @@ import static org.junit.Assert.fail; */ public class MXMLFeatureTestsBase { + + private static final Logger logger = LogManager.getLogger(MXMLFeatureTestsBase.class); + private static final String NAMESPACE_2009 = "http://ns.adobe.com/mxml/2009"; protected void compileAndRun(String mxml, boolean withFramework, boolean withRPC, boolean withSpark, String[] otherOptions) { - System.out.println("Generating test:"); + logger.info("Generating test:"); // Write the MXML into a temp file. ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter(); @@ -109,7 +114,7 @@ public class MXMLFeatureTestsBase for(String arg : args) { cmdLine.append(arg).append(" "); } - System.out.println("Compiling test:\n" + cmdLine.toString()); + logger.info("Compiling test:\n" + cmdLine.toString()); int exitCode = mxmlc.mainNoExit(args.toArray(new String[args.size()])); // Check that there were no compilation problems. @@ -134,7 +139,7 @@ public class MXMLFeatureTestsBase String[] runArgs = new String[] { testAdapter.getFlashplayerDebugger().getPath(), swf }; try { - System.out.println("Executing test:\n" + Arrays.toString(runArgs)); + logger.info("Executing test:\n" + Arrays.toString(runArgs)); exitCode = executeCommandWithTimeout(runArgs, 40); } catch (Exception e) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/test/java/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java ---------------------------------------------------------------------- diff --git a/compiler/src/test/java/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java b/compiler/src/test/java/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java index 1598e9d..7fac3d8 100644 --- a/compiler/src/test/java/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java +++ b/compiler/src/test/java/org/apache/flex/compiler/internal/tree/mxml/MXMLNodeBaseTests.java @@ -31,6 +31,8 @@ import org.apache.flex.compiler.tree.mxml.IMXMLFileNode; import org.apache.flex.compiler.units.ICompilationUnit; import org.apache.flex.compiler.units.requests.ISyntaxTreeRequestResult; import org.apache.flex.utils.*; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Ignore; import java.io.BufferedWriter; @@ -50,6 +52,8 @@ import java.util.List; public class MXMLNodeBaseTests { + private static final Logger logger = LogManager.getLogger(MXMLNodeBaseTests.class); + protected static Workspace workspace = new Workspace(); protected FlexProject project; @@ -178,8 +182,9 @@ public class MXMLNodeBaseTests ICompilerProblem[] problems = result.getProblems(); if (problems != null && problems.length > 0) { - for (ICompilerProblem problem : problems) - System.out.printf("%s(%d): %s\n", problem.getSourcePath(), problem.getLine(), problem.toString()); + for (ICompilerProblem problem : problems) { + logger.info("%s(%d): %s\n", problem.getSourcePath(), problem.getLine(), problem.toString()); + } } } catch (InterruptedException e) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/87ad72a6/compiler/src/test/java/utils/FlashplayerSecurityHandler.java ---------------------------------------------------------------------- diff --git a/compiler/src/test/java/utils/FlashplayerSecurityHandler.java b/compiler/src/test/java/utils/FlashplayerSecurityHandler.java index 0de36a1..af644fe 100644 --- a/compiler/src/test/java/utils/FlashplayerSecurityHandler.java +++ b/compiler/src/test/java/utils/FlashplayerSecurityHandler.java @@ -16,6 +16,9 @@ package utils; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.SystemUtils; +import org.apache.flex.utils.Base64; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -33,11 +36,13 @@ import java.util.List; */ public class FlashplayerSecurityHandler { + private static final Logger logger = LogManager.getLogger(FlashplayerSecurityHandler.class); + public void trustFile(File directory) { File securityTrustFile = new File(getSecuritySettingsDirectory(), "apache-flex-maven-plugin.cfg"); if(!securityTrustFile.exists()) { - System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath()); + logger.info(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath()); try { if(!securityTrustFile.createNewFile()) { throw new RuntimeException("Could not create FlashPlayer security trust file at: " + @@ -48,7 +53,7 @@ public class FlashplayerSecurityHandler { securityTrustFile.getPath(), e); } } else { - System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath()); + logger.info(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath()); } // Check if the current directory is already listed in the file, if not, append it to the file. @@ -56,10 +61,10 @@ public class FlashplayerSecurityHandler { List<String> trustedDirectories = FileUtils.readLines(securityTrustFile, "UTF-8"); if(!trustedDirectories.contains(directory.getAbsolutePath())) { FileUtils.writeStringToFile(securityTrustFile, directory.getAbsolutePath() + "\n", "UTF-8", true); - System.out.println(" - Added directory '" + directory.getAbsolutePath() + + logger.info(" - Added directory '" + directory.getAbsolutePath() + "' to FlashPlayer security trust file at: " + securityTrustFile.getPath()); } else { - System.out.println(" - Directory '" + directory.getAbsolutePath() + + logger.info(" - Directory '" + directory.getAbsolutePath() + "' already listed in FlashPlayer security trust file at: " + securityTrustFile.getPath()); } } catch (IOException e) {