Esempio n. 1
0
    //Adds a column to the current row of the Logs
    public void Add(string column, object data)
    {
        //if IsReadOnly is true, it is impossible to add data to the logs
        if (IsReadOnly())
        {
            Debug.LogError("Impossible to add data to log " + Label + " while saving it");
            return;
        }
        //Checks if a new header has been added to the logs, if so adds NULL to each previous value for this header
        //Because the first row is the one that defines the headers, we don't check this when logging the first line
        if (RowCount > 0 && !logs.Keys.Contains(column))
        {
            logs.Add(column, new List <string>(Enumerable.Repeat("NULL", RowCount).ToList()));
            //Currently, if a new header is added durring the logging process, the possibility of logging the datastring
            //on the fly is disabled
            if (createStringOverTime)
            {
                Debug.LogError("Header " + column + " added durring logging process...\n" +
                               "aborting logging datastring on the fly");
                createStringOverTime = false;
                logString.Clear();
            }
        }

        //If the data added to the logs is already in the current row, terminates the current row and starts another one
        //We don't do this if we are logging Meta logs because there should be only one row in this case
        if (LogType == LogType.LogEachRow && CurrentLogRow.ContainsKey(column))
        {
            EndRow();
        }

        if (isLogStringReady)
        {
            isLogStringReady = false;
        }
        string dataStr = SanitizeString(ConvertToString(data));

        AddToDictIfNotExists(CurrentLogRow, column, dataStr);
    }
Esempio n. 2
0
    //Terminates the current row
    public void EndRow()
    {
        if (LogType == LogType.OneRowOverwrite && RowCount >= 1)
        {
            Debug.Log("Unable to log more than one row in OneRowOverwrite mode");
            return;
        }
        AddCommonColumns();
        foreach (var logsKey in logs.Keys)
        {
            if (!CurrentLogRow.ContainsKey(logsKey))
            {
                CurrentLogRow.Add(logsKey, "NULL");
            }
        }
        foreach (var pair in CurrentLogRow)
        {
            CreateOrAddToLogsDict(logs, pair.Key, pair.Value);
            if (createStringOverTime)
            {
                if (currentLineLogged.Length != 0)
                {
                    currentLineLogged.Append(fieldSeparator);
                }
                currentLineLogged.Append(pair.Value);
            }
        }

        if (createStringOverTime)
        {
            currentLineLogged.Append(lineSeparator);
            logString.Append(currentLineLogged);
            currentLineLogged.Clear();
        }
        CurrentLogRow.Clear();
        RowCount++;
    }