GMAudit.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.model;
  16. import java.io.File;
  17. import java.io.FileWriter;
  18. import java.io.IOException;
  19. import java.text.SimpleDateFormat;
  20. import java.util.Date;
  21. import java.util.logging.Level;
  22. import java.util.logging.Logger;
  23. import net.sf.l2j.gameserver.lib.Log;
  24. public class GMAudit
  25. {
  26. private static final Logger _log = Logger.getLogger(Log.class.getName());
  27. public static void auditGMAction(String gmName, String action, String target, String params)
  28. {
  29. new File("log/GMAudit").mkdirs();
  30. SimpleDateFormat formatter;
  31. formatter = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
  32. String today = formatter.format(new Date());
  33. try
  34. {
  35. File file = new File("log/GMAudit/" + gmName + ".txt");
  36. FileWriter save = new FileWriter(file, true);
  37. String out = (today + ">" + gmName + ">" + action + ">" + target + ">" + params + "\r\n");
  38. save.write(out);
  39. save.flush();
  40. save.close();
  41. save = null;
  42. file = null;
  43. }
  44. catch (IOException e)
  45. {
  46. _log.log(Level.SEVERE, "GMAudit for GM " + gmName +" could not be saved: ", e);
  47. }
  48. }
  49. public static void auditGMAction(String gmName, String action, String target)
  50. {
  51. auditGMAction(gmName, action, target, "");
  52. }
  53. }