Flex and Parsley Logging -
I am looking for the possibility of logging into my Flex 4.5 project. It should include errors in remote classes, error handlers, or hand-written messages. After reading a lot of webpages, the solution to the parcel seems good. I want to switch to this profile anyway.
The gain runtime is likely to configure logging behavior. But I did not understand the documentation. Perhaps because I am brandnew in parsley and Google has no proper results.
Have you done this before and it is possible to give some code snippets to me Thank you very much
Frank
EDIT: J_A_X due to proper criticism , I add my code because I have partially succeeded.
First let us configure a config file, because I want to configure logging behavior in runtime. This is a simple XML file in the project root.
& lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Objects xmlns = "http://www.spicefactory.org/parsley" xmlns: log = "http://www.spicefactory.org/parsley/flex/logging" xmlns: xsi = "http: // www. W3 Org / 2001 / XMLSchema-instance "xsi: schema location =" http://www.spicefactory.org/parsley http://www.spicefactory.org/parsley/schema/2.3/parsley-core.xsd http: // Www.spicefactory.org/parsley/flex/logging http://www.spicefactory.org/parsley/schema/2.3/parsley-logging-flex.xsd "& gt; & Lt; Log: target level = "info" type = "components.SocketTarget" & gt; & Lt; / Log: Goal & gt; & Lt; / Objects & gt; This is my application:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; S: Application xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns: s = "library: //ns.adobe.com/flex/spark" xmlns: mx = "library: // Ns.adobe.com/flex/mx "minWidth =" 955 "minHeight =" 600 "initialize =" onAppInitiallize (event) "xmlns: parsley =" http://www.spicefactory.org/parsley "& gt; & Lt; Fx: script & gt; & Lt ;! [CDATA [Import mx.controls.Label; Import mx.events.FlexEvent; Import mx.logging.log; Import org.spicefactory.lib.logging.LogContext; Import org.spicefactory.parsley.flex.logging.FlexLoggingXml Support; Protected function onAppInitiallize (Event: FlexEvent): Zero {FlexLoggingXmlSupport.initialize (); LogContext.getLogger (this); //Log.getLogger ("myCat").info("MyInfo "); } Safe Function Button 1_clicker (): Zero {loggatelogger (this.toString ()). Info ("myMessage"); Log.getLogger (this.toString ()) Fatal ("myMessage") .; }] & Gt; & Lt; / Fx: script & gt; & Lt; Fx: Announcements & gt; & Lt; Parsley: Contextbuilder & gt; & Lt; Parsley: XmlConfig file = "config.xml" /> & Lt; / Parsley: Contextbuilder & gt; & Lt; / Fx: Announcements & gt; & Lt; S: Click on the button = "Button 1_ClickHandler ()" label = "SendlogTopserly" /> & Lt; / S: Applications & gt; At this point, logging in the console of the flex builder will work, because Percyly uses Tracee Target by default. Now, I want to send my logfile to the socket. I wrote a strange hard target. Package de.axurit.components {import flash.net.Socket; Import mx.logging.AbstractTarget; Import mx.logging.LogEvent; Import mx.logging.targets.LineFormattedTarget; Public category SocketTarget has AbstractTarget {Private var _host: String; Private var _port: int; Private var_socket: socket; Public Function SocketTarget (host: string = "localhost", port: int = 8085) {_host = host; _port = port; _socket = new socket (host, port); Super(); } Override Public Function Log Event (Event: Log Avent): Zero {Trace ("Log Event" + Event Message); _socket.writeUTF (event.message + String.fromCharCode (13)); _socket.flush (); I can see the comment in the Python document The default target type created by this tag is a TraceTarget, you can explicitly declare other target types: < P> If I add type-attribute, then I get an error message "One or more errors in the bootstrap processor". I like the one I received after a typo.
Can you give me some hints, how can I send my logs to the socket destination?
You are creating sockets, but do not actually connect it, if you create log targets Going, then locating your class to the target and overriding the log function.
Comments
Post a Comment