fougerite / Fougerite

Fougerite Project is unofficial fork of Magma. Forked to develop it with community.
http://fougerite.com/
Other
4 stars 19 forks source link

Buffered Plugin.Log #67

Open mikecrews opened 10 years ago

mikecrews commented 10 years ago

Magma and Jint use File.AppendAllText to add a log line. This performs terribly when there are more than a handful of lines to log.

balu92 commented 10 years ago

What about a timer with a stringbuilder?

mikecrews commented 10 years ago

I was thinking of a dictionary<string, dictionary<string, string>> to accept the log message from Plugin.Log. Use StreamWriter with AutoFlush = false in the timer to write messages out to the right file. Close and reopen when activity is low.

The outer dictionary key is the plugin name, the inner dictionary is logfile, message.

balu92 commented 10 years ago

I wasn't thinking of an actuall stringbuilder, just like making our own. Since every Plugin has it's own instance we would need a Dictionary<string, string> only, where the first is the path, and the second is the actuall log. And a Timer would save it to the disk. Or just check, how long is the current log-string, and save it to disk, if it's long enogh.