Class to add the ability to output logged data to the PowerFlasher Socket Output Server.
Mostly just a simple conversion of Pablo Costantini’s LuminicBox.Log.TracePublisher code.
This code requires that the LuminicBox.Log classes are in your classpath when you compile it and that you have a SOS Server running to see the output on. Also bear in mind that connections to the SOS Server are subject to Flash’s security restrictions.
import com.kelvinluck.util.LogWrapper;
import com.kelvinluck.util.SOSLogPublisher;
LogWrapper.getInstance().init();
LogWrapper.getLog().addPublisher(new SOSLogPublisher("myAppsName"));
LogWrapper.getLog().fatal("This is a fatal error :'(");
LogWrapper.getLog().error("This is an error :(");
LogWrapper.getLog().warn("This is a warning, warning, warning");
LogWrapper.getLog().info("This is information");
LogWrapper.getLog().debug("This is debugging info");
LogWrapper.getLog().debug([1,2,3,{a:"Part A", b:"Part B"}, "Some text", 99]);
http://sos.powerflasher.de/doc/1-04/
http://www.luminicbox.com- /blog- /?page=post- &id=2
http://kelvinluck.com/article/logging-from-fame
Kelvin Luck derived from the work of Pablo Costantini
Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (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.mozilla.org/MPL/MPL-1.1.html
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.
$Id: SOSLogPublisher.as 37 2006-05-10 19:29:32Z kluck $
| com. kelvinluck. util. SOSLogPublisher | Class to add the ability to output logged data to the PowerFlasher Socket Output Server. |
| COL_FATAL | The colour of the background of log messages with a severity of FATAL |
| COL_ERROR | The colour of the background of log messages with a severity of ERROR |
| COL_WARN | The colour of the background of log messages with a severity of WARN |
| COL_INFO | The colour of the background of log messages with a severity of INFO |
| COL_DEBUG | The colour of the background of log messages with a severity of DEBUG |
| indent | Sets the string that is used to indent object blocks. |
| maxDepth | The maximum inspection depth. |
| SOSLogPublisher | Creates a SOSLogPublisher instance. |
| _sendCommand | Internal, private function that makes it easier to send a command without worrying about the null byte or other implementation details. |
| publish | Sends a log event through the socket to the SOS Server |
| analyzeObj | Takes an anything and returns a pretty printed version by recursively moving down the object tree |
| closeAllSockets | Loops over all created SOSLogPublishers and shuts down their connections. |
| toString | The name of the class of this object. |
private static var COL_FATAL: Number
The colour of the background of log messages with a severity of FATAL
private static var COL_ERROR: Number
The colour of the background of log messages with a severity of ERROR
private static var COL_WARN: Number
The colour of the background of log messages with a severity of WARN
private static var COL_INFO: Number
The colour of the background of log messages with a severity of INFO
private static var COL_DEBUG: Number
The colour of the background of log messages with a severity of DEBUG
var indent: String
Sets the string that is used to indent object blocks. Defaults to a tab but you can use anything you like (“| “ is good if you are logging to a monospace font in SOS)
function set maxDepth( value: Number )
The maximum inspection depth.
The default value is 4. The max. valid value is 255.
function SOSLogPublisher( appName: String, sosServer: String, sosPort: Number, maxDepth: Number )
Creates a SOSLogPublisher instance. Also initalises communications with SOS through an XMLSocket.
| appName | The name of this app. [defaults to “UNKNOWN”] |
| sosServer | The IP address of the SOS server. [defaults to localhost] |
| sosPort | The command port of the SOS server to connect to. |
| [defaults to 4444 | the default Log-Port]; |
| maxDepth | The maximum depth to inspect into objects / arrays. [defaults to 4] |
private function _sendCommand( command: String )
Internal, private function that makes it easier to send a command without worrying about the null byte or other implementation details.
Also makes it easier to switch between sending the command on the Command-Port (which seems to make sense but doesn’t activate the userful “Bring to front > During connection” functionality of SOS) and sending commands on the Log-Port (which has the overhead of 4 bytes per command).
| command | The XML to send as the command. |
function publish( e: LogEvent ):Void
Sends a log event through the socket to the SOS Server
| e | The <LogEvent> to log... |
private function analyzeObj( o, depth: Number ):String
Takes an anything and returns a pretty printed version by recursively moving down the object tree
Taken from the original LuminicBox.Log.TracePublisher code and slightly modified...
| o | The object to analyse |
| depth | How deep into the object tree we currently are |
<LuminicBox.Log.TracePublisher>
public static function closeAllSockets():Void
Loops over all created SOSLogPublishers and shuts down their connections. Use if e.g. you want to kill the connection to the SOS Server (so that it stops sitting on top) without killing the swf you are testing...
The colour of the background of log messages with a severity of FATAL
private static var COL_FATAL: Number
The colour of the background of log messages with a severity of ERROR
private static var COL_ERROR: Number
The colour of the background of log messages with a severity of WARN
private static var COL_WARN: Number
The colour of the background of log messages with a severity of INFO
private static var COL_INFO: Number
The colour of the background of log messages with a severity of DEBUG
private static var COL_DEBUG: Number
Sets the string that is used to indent object blocks.
var indent: String
The maximum inspection depth.
function set maxDepth( value: Number )
Creates a SOSLogPublisher instance.
function SOSLogPublisher( appName: String, sosServer: String, sosPort: Number, maxDepth: Number )
Internal, private function that makes it easier to send a command without worrying about the null byte or other implementation details.
private function _sendCommand( command: String )
Sends a log event through the socket to the SOS Server
function publish( e: LogEvent ):Void
Takes an anything and returns a pretty printed version by recursively moving down the object tree
private function analyzeObj( o, depth: Number ):String
Loops over all created SOSLogPublishers and shuts down their connections.
public static function closeAllSockets():Void
The name of the class of this object.
function toString():String