This is an automated email from the ASF dual-hosted git repository. gregdove pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit f2d58a5f4475fe0e934979cea04d6b9126ad91b1 Author: greg-dove <[email protected]> AuthorDate: Mon Nov 1 16:00:24 2021 +1300 Support request for ability to switch off AMF verbose logging in js (which is present in flash debug output). The easiest way to do this is with a different ClassAliasBead : <js:AMFClassAliasBead verboseLogging="false" /> --- .../Network/src/main/resources/basic-manifest.xml | 1 + .../apache/royale/net/beads/AMFClassAliasBead.as | 70 ++++++++++++++++++++++ .../royale/net/remoting/amf/AMF0AMF3Context.as | 5 +- .../royale/net/remoting/amf/AMFBinaryData.as | 9 ++- .../apache/royale/net/remoting/amf/AMFContext.as | 2 +- 5 files changed, 82 insertions(+), 5 deletions(-) diff --git a/frameworks/projects/Network/src/main/resources/basic-manifest.xml b/frameworks/projects/Network/src/main/resources/basic-manifest.xml index 74197fd..5218ee1 100644 --- a/frameworks/projects/Network/src/main/resources/basic-manifest.xml +++ b/frameworks/projects/Network/src/main/resources/basic-manifest.xml @@ -20,6 +20,7 @@ <componentPackage> <component id="AMF0SupportBead" class="org.apache.royale.net.remoting.amf.AMF0SupportBead"/> + <component id="AMFClassAliasBead" class="org.apache.royale.net.beads.AMFClassAliasBead"/> <component id="SimpleRemoteObject" class="org.apache.royale.net.SimpleRemoteObject"/> <component id="RemoteObject" class="org.apache.royale.net.RemoteObject"/> <component id="CompressedRemoteObject" class="org.apache.royale.net.CompressedRemoteObject"/> diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/beads/AMFClassAliasBead.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/beads/AMFClassAliasBead.as new file mode 100644 index 0000000..b9d8fbf --- /dev/null +++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/beads/AMFClassAliasBead.as @@ -0,0 +1,70 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.net.beads +{ + + COMPILE::JS + { + import org.apache.royale.net.remoting.amf.AMFBinaryData; + } + + import org.apache.royale.reflection.beads.ClassAliasBead; + + /** + * The AMFClassAliasBead class is an extension of the reflection + * ClassAliasBead and is useful where aliasing is for AMF serialization/deserialization support. + * It offers a simple option to reduce logging noise in JSRoyale debug builds by setting + * verboseLogging to false (it is true by default for debug builds). + * AMF Verbose logging is never present in JSRoyale release builds. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.9 + */ + public class AMFClassAliasBead extends ClassAliasBead + { + + + /** + * Whether or not AMF Verbose logging should be enabled in JSRoyale debug builds. + * AMF Verbose logging is never present in JSRoyale release builds. + * + * @default true + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.9 + */ + public function set verboseLogging(value:Boolean):void{ + COMPILE::JS{ + AMFBinaryData.verboseLogging = value; + } + } + public function get verboseLogging():Boolean{ + COMPILE::JS{ + return AMFBinaryData.verboseLogging; + } + COMPILE::SWF{ + return false; + } + } + } +} diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as index 85989c0..3d8f425 100644 --- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as +++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as @@ -448,9 +448,8 @@ package org.apache.royale.net.remoting.amf { } else if (localTraits.isDynamic) { obj[key] = fieldValue; } else { - //@todo - trace('unknown field ', key) - if (goog.DEBUG) { + //@todo add debug-only logging for error checks (e.g. ReferenceError: Error #1074: Illegal write to read-only property) + if (goog.DEBUG && AMFBinaryData.verboseLogging) { trace('ReferenceError: Error #1056: Cannot create property ' + key + ' on ' + localTraits.qName); } } diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as index 4413204..84388ab 100644 --- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as +++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as @@ -46,6 +46,13 @@ package org.apache.royale.net.remoting.amf { */ public class AMFBinaryData extends BinaryData implements IDataInput, IDataOutput { + /** + * For swf target this is not available, but for js (and possible other future targets) + * setting it to false will avoid verbose logging in debug builds, that may slow down execution if logging is excessive. + */ + COMPILE::JS + public static var verboseLogging:Boolean = goog.DEBUG; + COMPILE::JS private static var _propertyWriter:IDynamicPropertyWriter; COMPILE::JS @@ -184,7 +191,7 @@ package org.apache.royale.net.remoting.amf { var value:* = _serializationContext.readObjectExternal(); var err:Error = _serializationContext.getError(); if (err) { - if (goog.DEBUG){ + if (goog.DEBUG && AMFBinaryData.verboseLogging){ console.log('%c[AMFBinaryData.readObject] - Deserialization Error :'+ err.message,'color:red'); } throw new Error(err.message); diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as index f383a42..6ee0a22 100644 --- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as +++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as @@ -1034,7 +1034,7 @@ internal class AMFContext extends BinaryData implements IDataInput, IDataOutput, obj[prop] = fieldValue; } else { //@todo add debug-only logging for error checks (e.g. ReferenceError: Error #1074: Illegal write to read-only property) - if (goog.DEBUG) { + if (goog.DEBUG && AMFBinaryData.verboseLogging) { trace('ReferenceError: Error #1056: Cannot create property ' + prop + ' on ' + localTraits.qName); } }
