Open mikecrews opened 10 years ago
What about a timer with a stringbuilder?
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.
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.
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.