LogToFile method performance issues
LogToFile was added as a temporary replacement to methods removed in Rust many months ago; it was never intended to be a permenant fix. We will be offering replacements in the uMod builds, once available. The current bottleneck is that there is no queue or cache, just direct to file logging, which can be resource intensive.
@Wulf , what is alternative method for log? What you think?
May be API http requsts, or MySQL or NoSQL  ?
 


Merged post

for Logger plugin.
Dictionary<string,List<string>> cacheLogs = new Dictionary<string,List<string>>();

Dictionary<string,int> numRowsToFlush = new Dictionary<string,int>()
{
    {"chat", 10},
    {"commands", 100},
    {"containers", 150},
    {"crafting", 500},
    {"deaths", 10},
    {"destroies", 100},
    {"itemdrops", 10},
    {"respawns", 10}
};

private void Log(string filename, string key, params object[] args)
{
    if (config.LogToConsole)
        Puts(Lang(key, null, args));

    string logRow = $"[{DateTime.Now}] {Lang(key, null, args)}";

    if (!numRowsToFlush.ContainsKey(filename)) {
        LogToFile(filename, logRow, this);
        return;
    }

    if (!cacheLogs.ContainsKey(filename))
        cacheLogs[filename] = new List<string>();

    cacheLogs[filename].Add(logRow);

    if (cacheLogs[filename].Count >= numRowsToFlush[filename]) {
        LogToFile(filename, string.Join("\n", cacheLogs[filename]), this);
        cacheLogs.Remove(filename);
    }
}

private void Unload()
{
    foreach (KeyValuePair<string,List<string>> row in cacheLogs)
        if (row.Value.Count > 0)
            LogToFile(row.Key, string.Join("\n", row.Value), this);
}
Miracle
@Wulf , what is alternative method for log? What you think?
May be API http requsts, or MySQL or NoSQL  ?
 


Merged post

for Logger plugin.
Dictionary<string,List<string>> cacheLogs = new Dictionary<string,List<string>>();

Dictionary<string,int> numRowsToFlush = new Dictionary<string,int>()
{
    {"chat", 10},
    {"commands", 100},
    {"containers", 150},
    {"crafting", 500},
    {"deaths", 10},
    {"destroies", 100},
    {"itemdrops", 10},
    {"respawns", 10}
};

private void Log(string filename, string key, params object[] args)
{
    if (config.LogToConsole)
        Puts(Lang(key, null, args));

    string logRow = $"[{DateTime.Now}] {Lang(key, null, args)}";

    if (!numRowsToFlush.ContainsKey(filename)) {
        LogToFile(filename, logRow, this);
        return;
    }

    if (!cacheLogs.ContainsKey(filename))
        cacheLogs[filename] = new List<string>();

    cacheLogs[filename].Add(logRow);

    if (cacheLogs[filename].Count >= numRowsToFlush[filename]) {
        LogToFile(filename, string.Join("\n", cacheLogs[filename]), this);
        cacheLogs.Remove(filename);
    }
}

private void Unload()
{
    foreach (KeyValuePair<string,List<string>> row in cacheLogs)
        if (row.Value.Count > 0)
            LogToFile(row.Key, string.Join("\n", row.Value), this);
}

MYSQL, SQL is too complicated for simple log plugin