source: trunk/fl5/src/com/longtailvideo/jwplayer/utils/Logger.as @ 396

Revision 396, 3.4 KB checked in by pablo, 4 years ago (diff)

Implemented clone() on all custom events.
Stretch media to config.stretching
PlayerReady from JavascriptAPI.as
config.file => config.playlist if file has .xml suffix
PluginConfig uses dynamic properties
V4ControlBar dispatches V5 view events
Media placed on stage!

Line 
1package com.longtailvideo.jwplayer.utils {
2        import flash.events.StatusEvent;
3        import flash.external.ExternalInterface;
4        import flash.net.LocalConnection;
5        import flash.net.SharedObject;
6       
7       
8        /**
9         * <p>Utility class for logging debug messages. It supports the following logging systems:</p>
10         * <ul>
11         * <li>The standalone Arthropod AIR application.</li>
12         * <li>The Console.log function built into Firefox/Firebug.</li>
13         * <li>The tracing sstem built into the debugging players.</li>
14         * </ul>
15         *
16         **/
17        public class Logger {
18                /** Constant defining the Arthropod output type. **/
19                public static const ARTHROPOD:String = "arthropod";
20                /** LocalConnection instance arthropod use. **/
21                private static const CONNECTION:LocalConnection = new LocalConnection();
22                /** Arthropod connection name. **/
23                private static const CONNECTION_NAME:String = 'app#com.carlcalderon.Arthropod.161E714B6C1A76DE7B9865F88B32FCCE8FABA7B5.1:arthropod';
24                /** Constant defining the Firefox/Firebug console output type. **/
25                public static const CONSOLE:String = "console";
26                /** Constant defining there's no output. **/
27                public static const NONE:String = "none";
28                /** Constant defining the Flash tracing output type. **/
29                public static const TRACE:String = "trace";
30                /** Latest output position. **/
31                private static var _output:String = Logger.NONE;
32               
33               
34                /**
35                 * Log a message to the output system.
36                 *
37                 * @param message       The message to send forward. Arrays and objects are automatically chopped up.
38                 * @param type          The type of message; is capitalized and encapsulates the message.
39                 **/
40                public static function log(message:*, type:String = "log"):void {
41                        if (message == undefined) {
42                                send(type.toUpperCase());
43                        } else if (message is String) {
44                                send(type.toUpperCase() + ' (' + message + ')');
45                        } else if (message is Boolean || message is Number || message is Array) {
46                                send(type.toUpperCase() + ' (' + message.toString() + ')');
47                        } else {
48                                Logger.object(message, type);
49                        }
50                }
51               
52               
53                /** Explode an object for logging. **/
54                private static function object(message:Object, type:String):void {
55                        var txt:String = type.toUpperCase() + ' (';
56                        Strings.print_r(message);
57                        txt += ')';
58                        Logger.send(txt);
59                }
60               
61               
62                /**
63                 * Set output system to use for logging. The output is also saved in a cookie.
64                 *
65                 * @param put   System to use (ARTHROPOD, CONSOLE, TRACE or NONE).StatusEvent
66                 **/
67                public static function set output(put:String):void {
68                        if (put == ARTHROPOD) {
69                                CONNECTION.allowInsecureDomain('*');
70                                CONNECTION.addEventListener(StatusEvent.STATUS, Logger.status);
71                        }
72                        SharedObject.getLocal('com.longtailvideo.jwplayer', '/').data['debug'] = put;
73                        Logger._output = put;
74                }
75               
76               
77                /**
78                 * Get output system to use for logging.
79                 *
80                 * @return      System to use (ARTHROPOD, CONSOLE, TRACE or NONE).
81                 **/
82                public static function get output():String {
83                        return Logger._output;
84                }
85               
86               
87                /** Send the messages to the output system. **/
88                private static function send(text:String):void {
89                        switch (Logger._output) {
90                                case ARTHROPOD:
91                                        CONNECTION.send(CONNECTION_NAME, 'debug', 'CDC309AF', text,     0xCCCCCC);
92                                        break;
93                                case CONSOLE:
94                                        ExternalInterface.call('console.log', text);
95                                        break;
96                                case TRACE:
97                                        trace(text);
98                                        break;
99                                case NONE:
100                                        break;
101                                default:
102                                        ExternalInterface.call(Logger._output, text);
103                                        break;
104                        }
105                }
106               
107               
108                /** Manage the status call of localconnection. **/
109                private static function status(evt:StatusEvent):void {
110                }
111        }
112}
Note: See TracBrowser for help on using the repository browser.