mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-10 00:13:42 -04:00
Added data logger with a bit of implementation in ObjectManager
This commit is contained in:
@@ -27,6 +27,9 @@
|
||||
***********************************************************************************/
|
||||
package resources.control;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import network.OutboundPacketService;
|
||||
import network.packets.Packet;
|
||||
import resources.config.ConfigFile;
|
||||
@@ -42,6 +45,7 @@ import resources.services.Config;
|
||||
public class Service implements IntentReceiver {
|
||||
|
||||
private static final OutboundPacketService outboundPacketService = new OutboundPacketService();
|
||||
private static final DateFormat LOG_FORMAT = new SimpleDateFormat("dd-mm-yy HH:mm:ss.SSS");
|
||||
|
||||
/**
|
||||
* Initializes this service. If the service returns false on this method
|
||||
@@ -160,6 +164,19 @@ public class Service implements IntentReceiver {
|
||||
return DataManager.getInstance().getLocalDatabase();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs the string to the server log file, formatted to display the time,
|
||||
* tag and message.
|
||||
* @param tag the tag to use for the log
|
||||
* @param str the format string for the log
|
||||
* @param args the string format arguments, if specified
|
||||
*/
|
||||
public synchronized final void log(String tag, String str, Object ... args) {
|
||||
if (getConfig(ConfigFile.PRIMARY).getBoolean("DEBUG-SERVICES", true)) {
|
||||
String logStr = String.format(str, args);
|
||||
String log = String.format("%s [%s]: %s", LOG_FORMAT.format(System.currentTimeMillis()), tag, logStr);
|
||||
DataManager.getInstance().log(log);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user