Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

[mini-mod] Clear all system logs

I HATE HATE HATE looking at resolved system logs. Especially when it's the first thing I see when I login. Oh look, old logs, yay. :mad:

This "mini-mod" will add a "Clear ALL!" button to your syslog page. Clicking the button will truncate the syslog table and refresh the page. Insta-clear syslogs!

open up include/staff/syslogs.inc.php

Find this code...

<input type=\"submit\" Value=\"Go!\" />


Directly beneath it, add this code...

<input type=\"button\"  style=\"background-color:red; color:#fff;\" name=\"clear\" value=\"Clear ALL!\" onClick=\"<?=mysql_query('TRUNCATE TABLE ost_syslog');
?>, history.go(0)\"/>


image


I added a bunch of spaces to keep myself from accidentally hitting the button. :D

Comments

  • Another mod for SysLog page

    Yeah, you are right.

    I also created the similar mod in order to improve some functionalities in this SysLog page, including how to remove the selected syslog record(s) easily.

    Hope it helps! :)

    Sincerely,
    Masino Sinaga
  • This "mini-mod" will add a "Clear ALL!" button to your syslog page. Clicking the button will truncate the syslog table and refresh the page. Insta-clear syslogs!
    Hang on boys and girls. Before you get all happy with this suggestion, simply adding this code as described will DELETE your logs by just VISITING the "System Logs" page. This is because this code makes the call to "TRUNCATE..." without clicking on Anything!! I personally tested this on 2 different sites with 2 different SQL databases. I was wondering, after installing this code, why the logs were there on one visit, and gone the next without clicking on the "red button". My fault, I should have examined the code before adding it. Big bad on my end, but those logs were just test logs anyways.

    Just wanted everyone to know this before they add this MOD. Thanks.

    EDIT: Now, 2 hours later...

    Try this one on for size... Just 2 easy steps...

    open /scp/admin.php

    Find this code (around line 570):
    $nav->addSubMenu(array('desc'=>'System Logs','href'=>'admin.php?t=syslog','iconclass'=>'syslogs'));


    Just under that line, add this line:
    $nav->addSubMenu(array('desc'=>'Delete All Logs','href'=>'admin.php?t=delsyslog','iconclass'=>'banList'));


    You will end up with this:
        case 'syslog':
    $nav->setTabActive('dashboard');
    $nav->addSubMenu(array('desc'=>'System Logs','href'=>'admin.php?t=syslog','iconclass'=>'syslogs'));
    $nav->addSubMenu(array('desc'=>'Delete All Logs','href'=>'admin.php?t=delsyslog','iconclass'=>'banList'));
    $page='syslogs.inc.php';
    break;


    Then right under that section, add this code:
        case 'delsyslog':
    $nav->setTabActive('dashboard');
    $nav->addSubMenu(array('desc'=>'System Logs','href'=>'admin.php?t=syslog','iconclass'=>'syslogs'));
    $nav->addSubMenu(array('desc'=>'Delete Logs','href'=>'admin.php?t=delsyslog','iconclass'=>'banList'));
    mysql_query('TRUNCATE TABLE '.SYSLOG_TABLE.' ');
    $page='syslogs.inc.php';
    break;


    This will add a new link titled 'Delete All Logs' in your 'Dashboard', and when you click on it, it will do just that. It will not give you any note saying that, the logs will just be empty. Any suggestions or improvements are always appreciated. :)
  • Thank you that was very helpful
  • AlphaDesignsGroup;23880 said:
    ... simply adding this code as described will DELETE your logs by just VISITING the "System Logs" page. This is because this code makes the call to "TRUNCATE..." without clicking on Anything!!
    Well, I don't think removing all log records by visitting that syslog page is a good idea, because you as Administrator sometimes want to check the last error message that has just occured in your osTicket system. This is very important somehow to confirm to the developer each time something unusual happened in your osTicket, then that related error log can be used to help developer to analyze the causes of the error.
    AlphaDesignsGroup;23880 said:
    ... This will add a new link titled 'Delete All Logs' in your 'Dashboard', and when you click on it, it will do just that. It will not give you any note saying that, the logs will just be empty. Any suggestions or improvements are always appreciated. :)
    My suggestion is, you should not clear all log records each time admin visit the syslog page. Adding the "Delete All Logs" link in the syslog page is the best approach for this.

    Sincerely,
    Masino Sinaga
  • Re: [mini-mod] Clear all system logs

    Oh Awesome, I was searching this, I'm gonna use this :)
    Thank you very much :D
  • @teryakisan

    it does not work for me :(
    I am not fluent with PHP code, and here is my code snippet:

    <input type="submit" Value="Go!" />
    <input type="button" style="background-color:red; color:#fff;" name="clear" value="Clear ALL!" onClick="mysql_query('TRUNCATE TABLE ost_syslog'); history.go(0)"/>

    The red button was there, but when I clicked that button .. nothing happened.

    Some enlightment please ...
  • @abubobe
    This thread was written in 2011 for version 1.6ST.
    IT was not updated for any versions between then and now.
    Are you really using a version that old?
  • @ntozier

    :)

    I was using v1.9.3 at that time.

Sign In or Register to comment.