martin
martin

Reputation: 55

How to write trace output to a text file without a web server in AS3

I have an application that writes traces with a timestamp when certain items are clicked or accessed. I need to write these to a text log file so that they can be accessed remotely.. The device the app runs on doesn't have a web server and doesn't run the flash debug player, os is xp. How can I send these traces to a text file? I noticed Arthropod writes to an html file, but I need to do this automatically without interaction.. any suggestions?

Upvotes: 1

Views: 3152

Answers (4)

jspooner
jspooner

Reputation: 11315

I had this same problem with my video player. Here is what I came up with.

I created a static Log class that I use instead of trace.

Log.s("[info] Bla.onRemove")

Then inside the static s method I push the string into an array and trace the string. I added a right click option to copy the logs to their clipboard. Oh your might want to encrypt the logs so the user doesn't see them.

I had doubt about pushing this many items into an array. But after some profiling and testing I had over 60k items in the array and I didn't see any memory increase so I guess its fairly safe.

My other ideas was to make an AIR app and connect it via LocalConnection but I had some issues getting that connection to work. Although I have a lot less confidence in the stability of LocalConnections.

If you like this solution and want to see more code let me know.

Upvotes: 1

Les
Les

Reputation: 2316

Adobe AIR is definitely the way to go, some obscure other possibilities could be:

use Flash 5 and fscommand("save", "file.txt"); see a post on moock.org

or you can store the data in a SharedObject and try to access the objects on the harddrive. More information here

Upvotes: 1

user105813
user105813

Reputation: 17497

Adobe Air provides a file I/O API via the FileStream class.

You can also use it's embedded SQLite db if you need to store full logs.

Upvotes: 2

sergiogx
sergiogx

Reputation: 1582

You could set up a web host and write a web service that creates a log file or stores it on a database, and call the web service.

Or you could use something like dropbox or syncplicity to sync the local text file to their servers or another computer

Upvotes: 0

Related Questions