Skip to content

Add ability to clear individual server logs #363

@KHerron

Description

@KHerron

I have already implemented this on my setup and it is working.
However, to not pile on more work for the release of 049, I will wait till after the release.

This requires a new Stored Procedure added to the database, and a code change to the OSAE.General.OSAELog and the logs.aspx.cs file. (See Below)
This enhancement will only clear the selected log in the Source drop down.
To clear all logs, simply select ALL, then click clear.
But now you can just clear one log should you need too!

The new stored procedure is as follows:

CREATE DEFINER=`osae`@`%` PROCEDURE `osae_sp_server_log_clear_logger`(IN logID text)
BEGIN
 DELETE
   FROM osae_log
   WHERE Logger = logID;
END

The new code in OSAE.General.OSAELog is as follows:

public static void Clear_Log(string log)
        {
            using (MySqlCommand command = new MySqlCommand())
            {
                command.CommandText = "CALL osae_sp_server_log_clear_logger(@log)";
                command.Parameters.AddWithValue("@log", log);
                try
                { OSAESql.RunQuery(command); }
                catch (Exception ex)
                { throw ex; }
            }
        }

The code changes in the logs.aspx.cs is as follows:

protected void btnClear_Click(object sender, EventArgs e)
    {
        DropDownList ddlSource2 = (DropDownList)gvLog.HeaderRow.FindControl("ddlSource");
        if (ddlSource2.Text == "All")
        {
            OSAE.General.OSAELog.Clear();
        }
        else
        {
            OSAE.General.OSAELog.Clear_Log(ddlSource2.Text);
            Response.Redirect("~/logs.aspx");
        }
        GetLogs();   
    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions