Updated logger formatters.

This commit is contained in:
MobiusDev
2018-05-11 22:28:35 +00:00
parent d82c8e3575
commit acf006c7ba
28 changed files with 678 additions and 547 deletions

View File

@ -0,0 +1,276 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jmobius.commons.util;
import com.l2jmobius.Config;
/**
* String utilities optimized for the best performance.<br>
* <h1>How to Use It</h1>
* <h2>concat() or append()</h2> If concatenating strings<br>
* in single call, use StringUtil.concat(), otherwise use StringUtil.append()<br>
* and its variants.<br>
* <br>
* <h2>Minimum Calls</h2><br>
* Bad:
*
* <pre>
* final StringBuilder sbString = new StringBuilder();
* StringUtil.append(sbString, &quot;text 1&quot;, String.valueOf(npcId));
* StringUtil.append(&quot;text 2&quot;);
* </pre>
*
* Good:
*
* <pre>
* final StringBuilder sbString = new StringBuilder();
* StringUtil.append(sbString, &quot;text 1&quot;, String.valueOf(npcId), &quot;text 2&quot;);
* </pre>
*
* Why?<br/>
* Because the less calls you do, the less memory re-allocations have to be done<br>
* so the whole text fits into the memory and less array copy tasks has to be<br>
* performed. So if using less calls, less memory is used and string concatenation is faster.<br>
* <br>
* <h2>Size Hints for Loops</h2><br>
* Bad:
*
* <pre>
* final StringBuilder sbString = new StringBuilder();
* StringUtil.append(sbString, &quot;header start&quot;, someText, &quot;header end&quot;);
* for (int i = 0; i &lt; 50; i++)
* {
* StringUtil.append(sbString, &quot;text 1&quot;, stringArray[i], &quot;text 2&quot;);
* }
* </pre>
*
* Good:
*
* <pre>
* final StringBuilder sbString = StringUtil.startAppend(1300, &quot;header start&quot;, someText, &quot;header end&quot;);
* for (int i = 0; i &lt; 50; i++)
* {
* StringUtil.append(sbString, &quot;text 1&quot;, stringArray[i], &quot;text 2&quot;);
* }
* </pre>
*
* Why?<br/>
* When using StringUtil.append(), memory is only allocated to fit in the strings in method argument. So on each loop new memory for the string has to be allocated and old string has to be copied to the new string. With size hint, even if the size hint is above the needed memory, memory is saved
* because new memory has not to be allocated on each cycle. Also it is much faster if no string copy tasks has to be performed. So if concatenating strings in a loop, count approximately the size and set it as the hint for the string builder size. It's better to make the size hint little bit larger
* rather than smaller.<br/>
* In case there is no text appended before the cycle, just use <code>new
* StringBuilder(1300)</code>.<br>
* <br>
* <h2>Concatenation and Constants</h2><br>
* Bad:
*
* <pre>
* StringUtil.concat(&quot;text 1 &quot;, &quot;text 2&quot;, String.valueOf(npcId));
* </pre>
*
* Good:
*
* <pre>
* StringUtil.concat(&quot;text 1 &quot; + &quot;text 2&quot;, String.valueOf(npcId));
* </pre>
*
* or
*
* <pre>
* StringUtil.concat(&quot;text 1 text 2&quot;, String.valueOf(npcId));
* </pre>
*
* Why?<br/>
* It saves some cycles when determining size of memory that needs to be allocated because less strings are passed to concat() method. But do not use + for concatenation of non-constant strings, that degrades performance and makes extra memory allocations needed.<br>
* <h2>Concatenation and Constant Variables</h2> Bad:
*
* <pre>
* String glue = &quot;some glue&quot;;
* StringUtil.concat(&quot;text 1&quot;, glue, &quot;text 2&quot;, glue, String.valueOf(npcId));
* </pre>
*
* Good:
*
* <pre>
* final String glue = &quot;some glue&quot;;
* StringUtil.concat(&quot;text 1&quot; + glue + &quot;text2&quot; + glue, String.valueOf(npcId));
* </pre>
*
* Why? Because when using <code>final</code> keyword, the <code>glue</code> is marked as constant string and compiler treats it as a constant string so it is able to create string "text1some gluetext2some glue" during the compilation. But this only works in case the value is known at compilation
* time, so this cannot be used for cases like <code>final String objectIdString =
* String.valueOf(getObjectId)</code>.<br>
* <br>
* <h2>StringBuilder Reuse</h2><br>
* Bad:
*
* <pre>
* final StringBuilder sbString1 = new StringBuilder();
* StringUtil.append(sbString1, &quot;text 1&quot;, String.valueOf(npcId), &quot;text 2&quot;);
* ... // output of sbString1, it is no more needed
* final StringBuilder sbString2 = new StringBuilder();
* StringUtil.append(sbString2, &quot;text 3&quot;, String.valueOf(npcId), &quot;text 4&quot;);
* </pre>
*
* Good:
*
* <pre>
* final StringBuilder sbString = new StringBuilder();
* StringUtil.append(sbString, &quot;text 1&quot;, String.valueOf(npcId), &quot;text 2&quot;);
* ... // output of sbString, it is no more needed
* sbString.setLength(0);
* StringUtil.append(sbString, &quot;text 3&quot;, String.valueOf(npcId), &quot;text 4&quot;);
* </pre>
*
* Why?</br>
* In first case, new memory has to be allocated for the second string. In second case already allocated memory is reused, but only in case the new string is not longer than the previously allocated string. Anyway, the second way is better because the string either fits in the memory and some memory
* is saved, or it does not fit in the memory, and in that case it works as in the first case.
* <h2>Primitives to Strings</h2> To convert primitives to string, use String.valueOf().<br>
* <br>
* <h2>How much faster is it?</h2><br>
* Here are some results of my tests. Count is number of strings concatenated. Don't take the numbers as 100% true as the numbers are affected by other programs running on my computer at the same time. Anyway, from the results it is obvious that using StringBuilder with predefined size is the
* fastest (and also most memory efficient) solution. It is about 5 times faster when concatenating 7 strings, compared to TextBuilder. Also, with more strings concatenated, the difference between StringBuilder and TextBuilder gets larger. In code, there are many cases, where there are concatenated
* 50+ strings so the time saving is even greater.<br>
*
* <pre>
* Count: 2
* TextBuilder: 1893
* TextBuilder with size: 1703
* String: 1033
* StringBuilder: 993
* StringBuilder with size: 1024
* Count: 3
* TextBuilder: 1973
* TextBuilder with size: 1872
* String: 2583
* StringBuilder: 1633
* StringBuilder with size: 1156
* Count: 4
* TextBuilder: 2188
* TextBuilder with size: 2229
* String: 4207
* StringBuilder: 1816
* StringBuilder with size: 1444
* Count: 5
* TextBuilder: 9185
* TextBuilder with size: 9464
* String: 6937
* StringBuilder: 2745
* StringBuilder with size: 1882
* Count: 6
* TextBuilder: 9785
* TextBuilder with size: 10082
* String: 9471
* StringBuilder: 2889
* StringBuilder with size: 1857
* Count: 7
* TextBuilder: 10169
* TextBuilder with size: 10528
* String: 12746
* StringBuilder: 3081
* StringBuilder with size: 2139
* </pre>
*
* @author fordfrog
*/
public final class StringUtil
{
private StringUtil()
{
}
/**
* Concatenates strings.
* @param strings strings to be concatenated
* @return concatenated string
*/
public static String concat(String... strings)
{
final StringBuilder sbString = new StringBuilder();
for (String string : strings)
{
sbString.append(string);
}
return sbString.toString();
}
/**
* Creates new string builder with size initializated to <code>sizeHint</code>, unless total length of strings is greater than <code>sizeHint</code>.
* @param sizeHint hint for string builder size allocation
* @param strings strings to be appended
* @return created string builder
*/
public static StringBuilder startAppend(int sizeHint, String... strings)
{
final int length = getLength(strings);
final StringBuilder sbString = new StringBuilder(sizeHint > length ? sizeHint : length);
for (String string : strings)
{
sbString.append(string);
}
return sbString;
}
/**
* Appends strings to existing string builder.
* @param sbString string builder
* @param strings strings to be appended
*/
public static void append(StringBuilder sbString, String... strings)
{
sbString.ensureCapacity(sbString.length() + getLength(strings));
for (String string : strings)
{
sbString.append(string);
}
}
public static int getLength(Iterable<String> strings)
{
int length = 0;
for (String string : strings)
{
length += (string == null) ? 4 : string.length();
}
return length;
}
/**
* Counts total length of all the strings.
* @param strings array of strings
* @return total length of all the strings
*/
public static int getLength(String[] strings)
{
int length = 0;
for (String string : strings)
{
length += (string == null) ? 4 : string.length();
}
return length;
}
public static String getTraceString(StackTraceElement[] trace)
{
final StringBuilder sbString = new StringBuilder();
for (StackTraceElement element : trace)
{
sbString.append(element.toString()).append(Config.EOL);
}
return sbString.toString();
}
}

View File

@ -25,7 +25,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -245,36 +244,50 @@ public class ItemTable
{
if (!Config.LOG_ITEMS_SMALL_LOG || (Config.LOG_ITEMS_SMALL_LOG && (item.isEquipable() || (item.getId() == ADENA_ID))))
{
final LogRecord record = new LogRecord(Level.INFO, "CREATE:" + process);
record.setLoggerName("item");
record.setParameters(new Object[]
if (item.getEnchantLevel() > 0)
{
item,
actor,
reference
});
LOGGER_ITEMS.log(record);
LOGGER_ITEMS.info("CREATE:" + String.valueOf(process) // in case of null
+ ", item " + item.getObjectId() //
+ ":+" + item.getEnchantLevel() //
+ " " + item.getItem().getName() //
+ "(" + item.getCount() //
+ "), " + String.valueOf(actor) // in case of null
+ ", " + String.valueOf(reference)); // in case of null
}
else
{
LOGGER_ITEMS.info("CREATE:" + String.valueOf(process) // in case of null
+ ", item " + item.getObjectId() //
+ ":" + item.getItem().getName() //
+ "(" + item.getCount() //
+ "), " + String.valueOf(actor) // in case of null
+ ", " + String.valueOf(reference)); // in case of null
}
}
}
if (actor != null)
if ((actor != null) && actor.isGM())
{
if (actor.isGM())
String referenceName = "no-reference";
if (reference instanceof L2Object)
{
String referenceName = "no-reference";
if (reference instanceof L2Object)
{
referenceName = (((L2Object) reference).getName() != null ? ((L2Object) reference).getName() : "no-name");
}
else if (reference instanceof String)
{
referenceName = (String) reference;
}
final String targetName = (actor.getTarget() != null ? actor.getTarget().getName() : "no-target");
if (Config.GMAUDIT)
{
GMAudit.auditGMAction(actor.getName() + " [" + actor.getObjectId() + "]", process + "(id: " + itemId + " count: " + count + " name: " + item.getItemName() + " objId: " + item.getObjectId() + ")", targetName, "L2Object referencing this action is: " + referenceName);
}
referenceName = (((L2Object) reference).getName() != null ? ((L2Object) reference).getName() : "no-name");
}
else if (reference instanceof String)
{
referenceName = (String) reference;
}
final String targetName = (actor.getTarget() != null ? actor.getTarget().getName() : "no-target");
if (Config.GMAUDIT)
{
GMAudit.auditGMAction(actor.getName() + " [" + actor.getObjectId() + "]" //
, String.valueOf(process) // in case of null
+ "(id: " + itemId //
+ " count: " + count //
+ " name: " + item.getItemName() //
+ " objId: " + item.getObjectId() + ")" //
, targetName //
, "L2Object referencing this action is: " + referenceName);
}
}
@ -318,37 +331,52 @@ public class ItemTable
{
if (!Config.LOG_ITEMS_SMALL_LOG || (Config.LOG_ITEMS_SMALL_LOG && (item.isEquipable() || (item.getId() == ADENA_ID))))
{
final LogRecord record = new LogRecord(Level.INFO, "DELETE:" + process);
record.setLoggerName("item");
record.setParameters(new Object[]
if (item.getEnchantLevel() > 0)
{
item,
"PrevCount(" + old + ")",
actor,
reference
});
LOGGER_ITEMS.log(record);
LOGGER_ITEMS.info("DELETE:" + String.valueOf(process) // in case of null
+ ", item " + item.getObjectId() //
+ ":+" + item.getEnchantLevel() //
+ " " + item.getItem().getName() //
+ "(" + item.getCount() //
+ "), PrevCount(" + old //
+ "), " + String.valueOf(actor) // in case of null
+ ", " + String.valueOf(reference)); // in case of null
}
else
{
LOGGER_ITEMS.info("DELETE:" + String.valueOf(process) // in case of null
+ ", item " + item.getObjectId() //
+ ":" + item.getItem().getName() //
+ "(" + item.getCount() //
+ "), PrevCount(" + old //
+ "), " + String.valueOf(actor) // in case of null
+ ", " + String.valueOf(reference)); // in case of null
}
}
}
if (actor != null)
if ((actor != null) && actor.isGM())
{
if (actor.isGM())
String referenceName = "no-reference";
if (reference instanceof L2Object)
{
String referenceName = "no-reference";
if (reference instanceof L2Object)
{
referenceName = (((L2Object) reference).getName() != null ? ((L2Object) reference).getName() : "no-name");
}
else if (reference instanceof String)
{
referenceName = (String) reference;
}
final String targetName = (actor.getTarget() != null ? actor.getTarget().getName() : "no-target");
if (Config.GMAUDIT)
{
GMAudit.auditGMAction(actor.getName() + " [" + actor.getObjectId() + "]", process + "(id: " + item.getId() + " count: " + item.getCount() + " itemObjId: " + item.getObjectId() + ")", targetName, "L2Object referencing this action is: " + referenceName);
}
referenceName = (((L2Object) reference).getName() != null ? ((L2Object) reference).getName() : "no-name");
}
else if (reference instanceof String)
{
referenceName = (String) reference;
}
final String targetName = (actor.getTarget() != null ? actor.getTarget().getName() : "no-target");
if (Config.GMAUDIT)
{
GMAudit.auditGMAction(actor.getName() + " [" + actor.getObjectId() + "]" //
, String.valueOf(process) // in case of null
+ "(id: " + item.getId() //
+ " count: " + item.getCount() //
+ " itemObjId: " //
+ item.getObjectId() + ")" //
, targetName //
, "L2Object referencing this action is: " + referenceName);
}
}

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.model.actor.tasks.player;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -76,12 +74,7 @@ public final class IllegalPlayerActionTask implements Runnable
@Override
public void run()
{
final LogRecord record = new LogRecord(Level.INFO, "AUDIT:" + _message);
record.setLoggerName("audit");
//@formatter:off
record.setParameters(new Object[] { _actor, _punishment });
//@formatter:on
LOGGER.log(record);
LOGGER.info("AUDIT, " + _message + ", " + _actor + ", " + _punishment);
AdminData.getInstance().broadcastMessageToGMs(_message);
if (!_actor.isGM())

View File

@ -28,7 +28,6 @@ import java.util.List;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -307,17 +306,30 @@ public final class L2ItemInstance extends L2Object
{
setOwnerId(owner_id);
if (Config.LOG_ITEMS && (!Config.LOG_ITEMS_SMALL_LOG || (Config.LOG_ITEMS_SMALL_LOG && (getItem().isEquipable() || (getItem().getId() == ADENA_ID)))))
if (Config.LOG_ITEMS)
{
final LogRecord record = new LogRecord(Level.INFO, "SETOWNER:" + process);
record.setLoggerName("item");
record.setParameters(new Object[]
if (!Config.LOG_ITEMS_SMALL_LOG || (Config.LOG_ITEMS_SMALL_LOG && (getItem().isEquipable() || (getItem().getId() == ADENA_ID))))
{
this,
creator,
reference
});
LOG_ITEMS.log(record);
if (getEnchantLevel() > 0)
{
LOG_ITEMS.info("SETOWNER:" + String.valueOf(process) // in case of null
+ ", item " + getObjectId() //
+ ":+" + getEnchantLevel() //
+ " " + getItem().getName() //
+ "(" + _count + "), " //
+ String.valueOf(creator) + ", " // in case of null
+ String.valueOf(reference)); // in case of null
}
else
{
LOG_ITEMS.info("SETOWNER:" + String.valueOf(process) // in case of null
+ ", item " + getObjectId() //
+ ":" + getItem().getName() //
+ "(" + _count + "), " //
+ String.valueOf(creator) + ", " // in case of null
+ String.valueOf(reference)); // in case of null
}
}
}
if ((creator != null) && creator.isGM())
@ -468,18 +480,32 @@ public final class L2ItemInstance extends L2Object
_storedInDb = false;
if (Config.LOG_ITEMS && (process != null) && (!Config.LOG_ITEMS_SMALL_LOG || (Config.LOG_ITEMS_SMALL_LOG && (_item.isEquipable() || (_item.getId() == ADENA_ID)))))
if (Config.LOG_ITEMS && (process != null))
{
final LogRecord record = new LogRecord(Level.INFO, "CHANGE:" + process);
record.setLoggerName("item");
record.setParameters(new Object[]
if (!Config.LOG_ITEMS_SMALL_LOG || (Config.LOG_ITEMS_SMALL_LOG && (_item.isEquipable() || (_item.getId() == ADENA_ID))))
{
this,
"PrevCount(" + old + ")",
creator,
reference
});
LOG_ITEMS.log(record);
if (getEnchantLevel() > 0)
{
LOG_ITEMS.info("CHANGE:" + String.valueOf(process) // in case of null
+ ", item " + getObjectId() //
+ ":+" + getEnchantLevel() //
+ " " + getItem().getName() //
+ "(" + _count + "), PrevCount(" //
+ String.valueOf(old) + "), " // in case of null
+ String.valueOf(creator) + ", " // in case of null
+ String.valueOf(reference)); // in case of null
}
else
{
LOG_ITEMS.info("CHANGE:" + String.valueOf(process) // in case of null
+ ", item " + getObjectId() //
+ ":" + getItem().getName() //
+ "(" + _count + "), PrevCount(" //
+ String.valueOf(old) + "), " // in case of null
+ String.valueOf(creator) + ", " // in case of null
+ String.valueOf(reference)); // in case of null
}
}
}
if ((creator != null) && creator.isGM())

View File

@ -33,7 +33,6 @@ import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -973,31 +972,26 @@ public class Olympiad extends ListenersContainer
return;
}
LogRecord record;
LOGGER_OLYMPIAD.info("Noble,charid,classid,compDone,points");
for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
if (NOBLES != null)
{
final StatsSet nobleInfo = entry.getValue();
if (nobleInfo == null)
LOGGER_OLYMPIAD.info("Noble,charid,classid,compDone,points");
StatsSet nobleInfo;
for (Entry<Integer, StatsSet> entry : NOBLES.entrySet())
{
continue;
nobleInfo = entry.getValue();
if (nobleInfo == null)
{
continue;
}
final int charId = entry.getKey();
final int classId = nobleInfo.getInt(CLASS_ID);
final String charName = nobleInfo.getString(CHAR_NAME);
final int points = nobleInfo.getInt(POINTS);
final int compDone = nobleInfo.getInt(COMP_DONE);
LOGGER_OLYMPIAD.info(charName + "," + charId + "," + classId + "," + compDone + "," + points);
}
final int charId = entry.getKey();
final int classId = nobleInfo.getInt(CLASS_ID);
final String charName = nobleInfo.getString(CHAR_NAME);
final int points = nobleInfo.getInt(POINTS);
final int compDone = nobleInfo.getInt(COMP_DONE);
record = new LogRecord(Level.INFO, charName);
record.setParameters(new Object[]
{
charId,
classId,
compDone,
points
});
LOGGER_OLYMPIAD.log(record);
}
try (Connection con = DatabaseFactory.getInstance().getConnection();
@ -1018,6 +1012,7 @@ public class Olympiad extends ListenersContainer
hero.set(CHAR_ID, rset.getInt(CHAR_ID));
hero.set(CHAR_NAME, rset.getString(CHAR_NAME));
LOGGER_OLYMPIAD.info("Hero " + hero.getString(CHAR_NAME) + "," + hero.getInt(CHAR_ID) + "," + hero.getInt(CLASS_ID));
if ((element == 132) || (element == 133)) // Male & Female Soulhounds rank as one hero class
{
hero = NOBLES.get(hero.getInt(CHAR_ID));
@ -1026,13 +1021,6 @@ public class Olympiad extends ListenersContainer
}
else
{
record = new LogRecord(Level.INFO, "Hero " + hero.getString(CHAR_NAME));
record.setParameters(new Object[]
{
hero.getInt(CHAR_ID),
hero.getInt(CLASS_ID)
});
LOGGER_OLYMPIAD.log(record);
HEROS_TO_BE.add(hero);
}
}
@ -1053,13 +1041,6 @@ public class Olympiad extends ListenersContainer
hero.set(CHAR_ID, winner.getInt(CHAR_ID));
hero.set(CHAR_NAME, winner.getString(CHAR_NAME));
record = new LogRecord(Level.INFO, "Hero " + hero.getString(CHAR_NAME));
record.setParameters(new Object[]
{
hero.getInt(CHAR_ID),
hero.getInt(CLASS_ID)
});
LOGGER_OLYMPIAD.log(record);
HEROS_TO_BE.add(hero);
break;
}
@ -1105,13 +1086,6 @@ public class Olympiad extends ListenersContainer
hero.set(CHAR_ID, winner.getInt(CHAR_ID));
hero.set(CHAR_NAME, winner.getString(CHAR_NAME));
record = new LogRecord(Level.INFO, "Hero " + hero.getString(CHAR_NAME));
record.setParameters(new Object[]
{
hero.getInt(CHAR_ID),
hero.getInt(CLASS_ID)
});
LOGGER_OLYMPIAD.log(record);
HEROS_TO_BE.add(hero);
break;
}

View File

@ -22,7 +22,6 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory;
@ -354,19 +353,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
if (Config.ALT_OLY_LOG_FIGHTS)
{
final LogRecord record = new LogRecord(Level.INFO, _playerOne.getName() + " default");
record.setParameters(new Object[]
{
_playerOne.getName(),
_playerTwo.getName(),
0,
0,
0,
0,
points,
getType().toString()
});
LOGGER_OLYMPIAD.log(record);
LOGGER_OLYMPIAD.info(_playerOne.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@ -393,19 +380,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
if (Config.ALT_OLY_LOG_FIGHTS)
{
final LogRecord record = new LogRecord(Level.INFO, _playerTwo.getName() + " default");
record.setParameters(new Object[]
{
_playerOne.getName(),
_playerTwo.getName(),
0,
0,
0,
0,
points,
getType().toString()
});
LOGGER_OLYMPIAD.log(record);
LOGGER_OLYMPIAD.info(_playerTwo.getName() + " default," + _playerOne + "," + _playerTwo + ",0,0,0,0," + points + "," + getType());
}
}
catch (Exception e)
@ -456,19 +431,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
if (Config.ALT_OLY_LOG_FIGHTS)
{
final LogRecord record = new LogRecord(Level.INFO, _playerTwo.getName() + " crash");
record.setParameters(new Object[]
{
_playerOne.getName(),
_playerTwo.getName(),
0,
0,
0,
0,
pointDiff,
getType().toString()
});
LOGGER_OLYMPIAD.log(record);
LOGGER_OLYMPIAD.info(_playerTwo.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
@ -494,19 +457,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
if (Config.ALT_OLY_LOG_FIGHTS)
{
final LogRecord record = new LogRecord(Level.INFO, _playerOne.getName() + " crash");
record.setParameters(new Object[]
{
_playerOne.getName(),
_playerTwo.getName(),
0,
0,
0,
0,
pointDiff,
getType().toString()
});
LOGGER_OLYMPIAD.log(record);
LOGGER_OLYMPIAD.info(_playerOne.getName() + " crash," + _playerOne + "," + _playerTwo + ",0,0,0,0," + pointDiff + "," + getType());
}
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnOlympiadMatchResult(_playerTwo, _playerOne, getType()), Olympiad.getInstance());
@ -527,19 +478,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
if (Config.ALT_OLY_LOG_FIGHTS)
{
final LogRecord record = new LogRecord(Level.INFO, "both crash");
record.setParameters(new Object[]
{
_playerOne.getName(),
_playerTwo.getName(),
0,
0,
0,
0,
pointDiff,
getType().toString()
});
LOGGER_OLYMPIAD.log(record);
LOGGER_OLYMPIAD.info("both crash," + _playerOne.getName() + "," + _playerOne + ",0,0,0,0," + _playerTwo + "," + pointDiff + "," + getType());
}
}
@ -699,19 +638,7 @@ public abstract class OlympiadGameNormal extends AbstractOlympiadGame
if (Config.ALT_OLY_LOG_FIGHTS)
{
final LogRecord record = new LogRecord(Level.INFO, winner);
record.setParameters(new Object[]
{
_playerOne.getName(),
_playerTwo.getName(),
playerOneHp,
playerTwoHp,
_damageP1,
_damageP2,
pointDiff,
getType().toString()
});
LOGGER_OLYMPIAD.log(record);
LOGGER_OLYMPIAD.info(winner + "," + _playerOne.getName() + "," + _playerOne + "," + _playerTwo + "," + playerOneHp + "," + playerTwoHp + "," + _damageP1 + "," + _damageP2 + "," + pointDiff + "," + getType());
}
}
catch (Exception e)

View File

@ -23,7 +23,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -327,13 +326,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
}
}
final LogRecord record = new LogRecord(Level.WARNING, "Delete");
record.setParameters(new Object[]
{
objectId,
this
});
LOGGER_ACCOUNTING.log(record);
LOGGER_ACCOUNTING.info("Delete, " + objectId + ", " + this);
}
}
return answer;
@ -364,13 +357,7 @@ public final class L2GameClient extends ChannelInboundHandler<L2GameClient>
LOGGER.log(Level.SEVERE, "Error restoring character.", e);
}
final LogRecord record = new LogRecord(Level.WARNING, "Restore");
record.setParameters(new Object[]
{
objectId,
this
});
LOGGER_ACCOUNTING.log(record);
LOGGER_ACCOUNTING.info("Restore, " + objectId + ", " + this);
}
public static void deleteCharByObjId(int objid)

View File

@ -17,8 +17,6 @@
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -244,13 +242,7 @@ public final class CharacterCreate implements IClientIncomingPacket
initNewChar(client, newChar);
final LogRecord record = new LogRecord(Level.INFO, "Created new character.");
record.setParameters(new Object[]
{
newChar,
client
});
LOGGER_ACCOUNTING.log(record);
LOGGER_ACCOUNTING.info("Created new character, " + newChar + ", " + client);
}
private boolean isValidName(String text)

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -180,12 +178,7 @@ public class CharacterSelect implements IClientIncomingPacket
client.getActiveCharLock().unlock();
}
final LogRecord record = new LogRecord(Level.INFO, "Logged in");
record.setParameters(new Object[]
{
client
});
LOGGER_ACCOUNTING.log(record);
LOGGER_ACCOUNTING.info("Logged in, " + client);
}
}
}

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.commons.network.PacketReader;
@ -60,12 +58,7 @@ public final class Logout implements IClientIncomingPacket
// Remove player from Boss Zone
player.removeFromBossZone();
final LogRecord record = new LogRecord(Level.INFO, "Disconnected");
record.setParameters(new Object[]
{
client
});
LOGGER_ACCOUNTING.log(record);
LOGGER_ACCOUNTING.info("Logged out, " + client);
if (!OfflineTradeUtil.enteredOfflineMode(player))
{

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -53,21 +51,13 @@ public final class ProtocolVersion implements IClientIncomingPacket
}
else if (!Config.PROTOCOL_LIST.contains(_version))
{
final LogRecord record = new LogRecord(Level.WARNING, "Wrong protocol");
record.setParameters(new Object[]
{
_version,
client
});
LOGGER_ACCOUNTING.log(record);
final KeyPacket pk = new KeyPacket(client.enableCrypt(), 0);
LOGGER_ACCOUNTING.warning("Wrong protocol version " + _version + ", " + client);
client.setProtocolOk(false);
client.close(pk);
client.close(new KeyPacket(client.enableCrypt(), 0));
}
else
{
final KeyPacket pk = new KeyPacket(client.enableCrypt(), 1);
client.sendPacket(pk);
client.sendPacket(new KeyPacket(client.enableCrypt(), 1));
client.setProtocolOk(true);
}
}

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -189,16 +187,25 @@ public final class RequestEnchantItem implements IClientIncomingPacket
if (Config.LOG_ITEM_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Success");
record.setParameters(new Object[]
if (item.getEnchantLevel() > 0)
{
activeChar,
item,
scroll,
support,
});
record.setLoggerName("item");
LOGGER_ENCHANT.log(record);
if (support == null)
{
LOGGER_ENCHANT.info("Success, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Success, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Success, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Success, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
// announce the success
@ -241,16 +248,25 @@ public final class RequestEnchantItem implements IClientIncomingPacket
if (Config.LOG_ITEM_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Safe Fail");
record.setParameters(new Object[]
if (item.getEnchantLevel() > 0)
{
activeChar,
item,
scroll,
support,
});
record.setLoggerName("item");
LOGGER_ENCHANT.log(record);
if (support == null)
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Safe Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
}
else
@ -293,23 +309,31 @@ public final class RequestEnchantItem implements IClientIncomingPacket
if (Config.LOG_ITEM_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Blessed Fail");
record.setParameters(new Object[]
if (item.getEnchantLevel() > 0)
{
activeChar,
item,
scroll,
support,
});
record.setLoggerName("item");
LOGGER_ENCHANT.log(record);
if (support == null)
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Blessed Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
}
else
{
// enchant failed, destroy item
item = activeChar.getInventory().destroyItem("Enchant", item, activeChar, null);
if (item == null)
if (activeChar.getInventory().destroyItem("Enchant", item, activeChar, null) == null)
{
// unable to destroy item, cheater ?
Util.handleIllegalPlayerAction(activeChar, "Unable to delete item on enchant failure from player " + activeChar.getName() + ", possible cheater !", Config.DEFAULT_PUNISH);
@ -318,16 +342,25 @@ public final class RequestEnchantItem implements IClientIncomingPacket
if (Config.LOG_ITEM_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Unable to destroy");
record.setParameters(new Object[]
if (item.getEnchantLevel() > 0)
{
activeChar,
item,
scroll,
support,
});
record.setLoggerName("item");
LOGGER_ENCHANT.log(record);
if (support == null)
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Unable to destroy, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
return;
}
@ -354,16 +387,25 @@ public final class RequestEnchantItem implements IClientIncomingPacket
if (Config.LOG_ITEM_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Fail");
record.setParameters(new Object[]
if (item.getEnchantLevel() > 0)
{
activeChar,
item,
scroll,
support,
});
record.setLoggerName("item");
LOGGER_ENCHANT.log(record);
if (support == null)
{
LOGGER_ENCHANT.info("Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", +" + item.getEnchantLevel() + " " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
else if (support == null)
{
LOGGER_ENCHANT.info("Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "]");
}
else
{
LOGGER_ENCHANT.info("Fail, Character:" + activeChar.getName() + " [" + activeChar.getObjectId() + "] Account:" + activeChar.getAccountName() + " IP:" + activeChar.getIPAddress() + ", " + item.getName() + "(" + item.getCount() + ") [" + item.getObjectId() + "], " + scroll.getName() + "(" + scroll.getCount() + ") [" + scroll.getObjectId() + "], " + support.getName() + "(" + support.getCount() + ") [" + support.getObjectId() + "]");
}
}
}
}

View File

@ -17,7 +17,6 @@
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -155,16 +154,7 @@ public final class RequestExEnchantSkill implements IClientIncomingPacket
{
if (Config.LOG_SKILL_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Success");
record.setParameters(new Object[]
{
player,
skill,
spb,
rate
});
record.setLoggerName("skill");
LOGGER_ENCHANT.log(record);
LOGGER_ENCHANT.log(Level.INFO, "Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", Skill:" + skill + ", SPB:" + spb + ", Rate:" + rate);
}
player.addSkill(skill, true);
@ -182,16 +172,7 @@ public final class RequestExEnchantSkill implements IClientIncomingPacket
if (Config.LOG_SKILL_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Fail");
record.setParameters(new Object[]
{
player,
skill,
spb,
rate
});
record.setLoggerName("skill");
LOGGER_ENCHANT.log(record);
LOGGER_ENCHANT.log(Level.INFO, "Failed, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", Skill:" + skill + ", SPB:" + spb + ", Rate:" + rate);
}
}

View File

@ -17,7 +17,6 @@
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -170,15 +169,7 @@ public final class RequestExEnchantSkillRouteChange implements IClientIncomingPa
{
if (Config.LOG_SKILL_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Route Change");
record.setParameters(new Object[]
{
player,
skill,
spb
});
record.setLoggerName("skill");
LOGGER_ENCHANT.log(record);
LOGGER_ENCHANT.log(Level.INFO, "Route Change:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", Skill:" + skill + ", SPB:" + spb);
}
player.addSkill(skill, true);

View File

@ -17,7 +17,6 @@
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -148,16 +147,7 @@ public final class RequestExEnchantSkillSafe implements IClientIncomingPacket
{
if (Config.LOG_SKILL_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Safe Success");
record.setParameters(new Object[]
{
player,
skill,
spb,
rate
});
record.setLoggerName("skill");
LOGGER_ENCHANT.log(record);
LOGGER_ENCHANT.log(Level.INFO, "Safe Success, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", Skill:" + skill + ", SPB:" + spb + ", Rate:" + rate);
}
player.addSkill(skill, true);
@ -172,16 +162,7 @@ public final class RequestExEnchantSkillSafe implements IClientIncomingPacket
{
if (Config.LOG_SKILL_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Safe Fail");
record.setParameters(new Object[]
{
player,
skill,
spb,
rate
});
record.setLoggerName("skill");
LOGGER_ENCHANT.log(record);
LOGGER_ENCHANT.log(Level.INFO, "Safe Failed, Character:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", Skill:" + skill + ", SPB:" + spb + ", Rate:" + rate);
}
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.SKILL_ENCHANT_FAILED_CURRENT_LEVEL_OF_ENCHANT_SKILL_S1_WILL_REMAIN_UNCHANGED);

View File

@ -17,7 +17,6 @@
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -154,15 +153,7 @@ public final class RequestExEnchantSkillUntrain implements IClientIncomingPacket
if (Config.LOG_SKILL_ENCHANTS)
{
final LogRecord record = new LogRecord(Level.INFO, "Untrain");
record.setParameters(new Object[]
{
player,
skill,
spb
});
record.setLoggerName("skill");
LOGGER_ENCHANT.log(record);
LOGGER_ENCHANT.log(Level.INFO, "Untrain:" + player.getName() + " [" + player.getObjectId() + "] Account:" + player.getAccountName() + " IP:" + player.getIPAddress() + ", Skill:" + skill + ", SPB:" + spb);
}
player.addSkill(skill, true);

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -128,12 +126,7 @@ public final class RequestRestart implements IClientIncomingPacket
// Remove player from Boss Zone
player.removeFromBossZone();
final LogRecord record = new LogRecord(Level.INFO, "Logged out");
record.setParameters(new Object[]
{
client
});
LOGGER_ACCOUNTING.log(record);
LOGGER_ACCOUNTING.info("Logged out, " + client);
if (!OfflineTradeUtil.enteredOfflineMode(player))
{

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -70,15 +68,7 @@ public final class RequestSendFriendMsg implements IClientIncomingPacket
if (Config.LOG_CHAT)
{
final LogRecord record = new LogRecord(Level.INFO, _message);
record.setLoggerName("chat");
record.setParameters(new Object[]
{
"PRIV_MSG",
"[" + activeChar.getName() + " to " + _reciever + "]"
});
LOGGER_CHAT.log(record);
LOGGER_CHAT.info("PRIV_MSG [" + activeChar + " to " + targetPlayer + "] " + _message);
}
targetPlayer.sendPacket(new L2FriendSay(activeChar.getName(), _reciever, _message));

View File

@ -16,8 +16,6 @@
*/
package com.l2jmobius.gameserver.network.clientpackets;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import com.l2jmobius.Config;
@ -172,27 +170,14 @@ public final class Say2 implements IClientIncomingPacket
if (Config.LOG_CHAT)
{
final LogRecord record = new LogRecord(Level.INFO, _text);
record.setLoggerName("chat");
if (chatType == ChatType.WHISPER)
{
record.setParameters(new Object[]
{
chatType.name(),
"[" + activeChar.getName() + " to " + _target + "]"
});
LOGGER_CHAT.info(chatType.name() + " [" + activeChar + " to " + _target + "] " + _text);
}
else
{
record.setParameters(new Object[]
{
chatType.name(),
"[" + activeChar.getName() + "]"
});
LOGGER_CHAT.info(chatType.name() + " [" + activeChar + "] " + _text);
}
LOGGER_CHAT.log(record);
}
if ((_text.indexOf(8) >= 0) && !parseAndPublishItem(activeChar))

View File

@ -16,21 +16,26 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.StringUtil;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.ConnectionState;
import com.l2jmobius.gameserver.network.L2GameClient;
public class AccountingFormatter extends AbstractFormatter
public class AccountingFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss");
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0));
output.append(super.format(record));
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage());
if (params != null)
{
@ -41,7 +46,7 @@ public class AccountingFormatter extends AbstractFormatter
continue;
}
output.append(", ");
StringUtil.append(output, ", ");
if (p instanceof L2GameClient)
{
@ -56,46 +61,50 @@ public class AccountingFormatter extends AbstractFormatter
}
catch (Exception e)
{
}
switch ((ConnectionState) client.getConnectionState())
{
case IN_GAME:
{
if (client.getActiveChar() != null)
{
output.append(client.getActiveChar().getName());
output.append("(");
output.append(client.getActiveChar().getObjectId());
output.append(") ");
}
case AUTHENTICATED:
if (client.getAccountName() != null)
{
output.append(client.getAccountName());
output.append(" ");
}
case CONNECTED:
if (address != null)
{
output.append(address);
StringUtil.append(output, client.getActiveChar().getName());
StringUtil.append(output, "(", String.valueOf(client.getActiveChar().getObjectId()), ") ");
}
break;
}
case AUTHENTICATED:
{
if (client.getAccountName() != null)
{
StringUtil.append(output, client.getAccountName(), " ");
}
break;
}
case CONNECTED:
{
if (address != null)
{
StringUtil.append(output, address);
}
break;
}
default:
{
throw new IllegalStateException("Missing state on switch");
}
}
}
else if (p instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) p;
output.append(player.getName());
output.append("(");
output.append(player.getObjectId());
output.append(")");
final L2PcInstance player = (L2PcInstance) p;
StringUtil.append(output, player.getName());
StringUtil.append(output, "(", String.valueOf(player.getObjectId()), ")");
}
else
{
output.append(p);
StringUtil.append(output, p.toString());
}
}
}

View File

@ -16,21 +16,26 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.StringUtil;
/**
* @author zabbix
*/
public class AuditFormatter extends AbstractFormatter
public class AuditFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss");
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0));
output.append(super.format(record));
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage());
if (params != null)
{
@ -40,12 +45,11 @@ public class AuditFormatter extends AbstractFormatter
{
continue;
}
output.append(", ");
output.append(p);
StringUtil.append(output, ", ", p.toString());
}
}
output.append(Config.EOL);
output.append(Config.EOL);
return output.toString();
}
}

View File

@ -16,30 +16,33 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.StringUtil;
public class ChatLogFormatter extends AbstractFormatter
public class ChatLogFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss");
@Override
public String format(LogRecord record)
{
Object[] params = record.getParameters();
final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0));
output.append(super.format(record));
final Object[] params = record.getParameters();
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params != null ? 10 * params.length : 0), "[", dateFmt.format(new Date(record.getMillis())), "] ");
if (params != null)
{
for (Object p : params)
{
output.append(p);
output.append(" ");
StringUtil.append(output, String.valueOf(p), " ");
}
}
output.append(record.getMessage());
output.append(Config.EOL);
StringUtil.append(output, record.getMessage(), Config.EOL);
return output.toString();
}

View File

@ -16,26 +16,30 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.CommonUtil;
import com.l2jmobius.commons.util.StringUtil;
public class ConsoleLogFormatter extends AbstractFormatter
public class ConsoleLogFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd/MM HH:mm:ss");
@Override
public String format(LogRecord record)
{
final StringBuilder output = new StringBuilder(128);
output.append(super.format(record));
output.append(Config.EOL);
final StringBuilder output = new StringBuilder(500);
StringUtil.append(output, "[", dateFmt.format(new Date(record.getMillis())), "] " + record.getMessage(), Config.EOL);
if (record.getThrown() != null)
{
try
{
output.append(CommonUtil.getStackTrace(record.getThrown()));
output.append(Config.EOL);
StringUtil.append(output, CommonUtil.getStackTrace(record.getThrown()), Config.EOL);
}
catch (Exception ex)
{

View File

@ -16,23 +16,27 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.commons.util.StringUtil;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
public class DamageFormatter extends AbstractFormatter
public class DamageFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("yy.MM.dd H:mm:ss");
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0));
output.append(super.format(record));
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] '---': ", record.getMessage());
if (params != null)
{
@ -45,40 +49,30 @@ public class DamageFormatter extends AbstractFormatter
if (p instanceof L2Character)
{
final L2Character creature = (L2Character) p;
if ((p instanceof L2Attackable) && ((L2Attackable) p).isRaid())
if ((p instanceof L2Character) && ((L2Character) p).isRaid())
{
output.append("RaidBoss ");
StringUtil.append(output, "RaidBoss ");
}
output.append(creature.getName());
output.append("(");
output.append(creature.getObjectId());
output.append(") ");
output.append(creature.getLevel());
output.append(" lvl");
StringUtil.append(output, ((L2Character) p).getName(), "(", String.valueOf(((L2Character) p).getObjectId()), ") ");
StringUtil.append(output, String.valueOf(((L2Character) p).getLevel()), " lvl");
if (p instanceof L2Summon)
{
L2PcInstance owner = ((L2Summon) p).getOwner();
final L2PcInstance owner = ((L2Summon) p).getOwner();
if (owner != null)
{
output.append(" Owner:");
output.append(owner.getName());
output.append("(");
output.append(owner.getObjectId());
output.append(")");
StringUtil.append(output, " Owner:", owner.getName(), "(", String.valueOf(owner.getObjectId()), ")");
}
}
}
else if (p instanceof Skill)
{
output.append(" with skill ");
output.append(p);
StringUtil.append(output, " with skill ", ((Skill) p).getName(), "(", String.valueOf(((Skill) p).getId()), ")");
}
else
{
output.append(p);
StringUtil.append(output, p.toString());
}
}
}

View File

@ -16,21 +16,26 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.StringUtil;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
public class EnchantFormatter extends AbstractFormatter
public class EnchantFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss");
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0));
output.append(super.format(record));
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage());
if (params != null)
{
@ -41,59 +46,39 @@ public class EnchantFormatter extends AbstractFormatter
continue;
}
output.append(", ");
StringUtil.append(output, ", ");
if (p instanceof L2PcInstance)
{
L2PcInstance player = (L2PcInstance) p;
output.append("Character:");
output.append(player.getName());
output.append(" [");
output.append(player.getObjectId());
output.append("] Account:");
output.append(player.getAccountName());
final L2PcInstance player = (L2PcInstance) p;
StringUtil.append(output, "Character:", player.getName(), " [" + player.getObjectId() + "] Account:", player.getAccountName());
if ((player.getClient() != null) && !player.getClient().isDetached())
{
output.append(" IP:");
output.append(player.getClient().getConnectionAddress().getHostAddress());
StringUtil.append(output, " IP:", player.getClient().getConnectionAddress().getHostAddress());
}
}
else if (p instanceof L2ItemInstance)
{
L2ItemInstance item = (L2ItemInstance) p;
final L2ItemInstance item = (L2ItemInstance) p;
if (item.getEnchantLevel() > 0)
{
output.append("+");
output.append(item.getEnchantLevel());
output.append(" ");
StringUtil.append(output, "+", String.valueOf(item.getEnchantLevel()), " ");
}
output.append(item.getItem().getName());
output.append("(");
output.append(item.getCount());
output.append(")");
output.append(" [");
output.append(item.getObjectId());
output.append("]");
StringUtil.append(output, item.getItem().getName(), "(", String.valueOf(item.getCount()), ")");
StringUtil.append(output, " [", String.valueOf(item.getObjectId()), "]");
}
else if (p instanceof Skill)
{
Skill skill = (Skill) p;
final Skill skill = (Skill) p;
if (skill.getLevel() > 100)
{
output.append("+");
output.append(skill.getLevel() % 100);
output.append(" ");
StringUtil.append(output, "+", String.valueOf(skill.getLevel() % 100), " ");
}
output.append(skill.getName());
output.append("(");
output.append(skill.getId());
output.append(" ");
output.append(skill.getLevel());
output.append(")");
StringUtil.append(output, skill.getName(), "(", String.valueOf(skill.getId()), " ", String.valueOf(skill.getLevel()), ")");
}
else
{
output.append(p);
StringUtil.append(output, p.toString());
}
}
}

View File

@ -18,11 +18,11 @@ package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringJoiner;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.StringUtil;
/**
* This class ...
@ -30,17 +30,12 @@ import com.l2jmobius.Config;
*/
public class FileLogFormatter extends Formatter
{
private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss,SSS");
private static final String TAB = "\t";
private final SimpleDateFormat dateFmt = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss,SSS");
@Override
public String format(LogRecord record)
{
final StringJoiner sj = new StringJoiner("\t", "", Config.EOL);
sj.add(dateFormat.format(new Date(record.getMillis())));
sj.add(record.getLevel().getName());
sj.add(String.valueOf(record.getThreadID()));
sj.add(record.getLoggerName());
sj.add(record.getMessage());
return sj.toString();
return StringUtil.concat(dateFmt.format(new Date(record.getMillis())), TAB, record.getLevel().getName(), TAB, String.valueOf(record.getThreadID()), TAB, record.getLoggerName(), TAB, record.getMessage(), Config.EOL);
}
}

View File

@ -16,51 +16,52 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.StringUtil;
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
/**
* @author Advi
*/
public class ItemLogFormatter extends AbstractFormatter
public class ItemLogFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM H:mm:ss");
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0));
output.append(super.format(record));
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params != null ? params.length * 50 : 0), "[", dateFmt.format(new Date(record.getMillis())), "] ", record.getMessage());
for (Object p : record.getParameters())
if (params != null)
{
if (p == null)
for (Object p : params)
{
continue;
}
output.append(", ");
if (p instanceof L2ItemInstance)
{
L2ItemInstance item = (L2ItemInstance) p;
output.append("item ");
output.append(item.getObjectId());
output.append(":");
if (item.getEnchantLevel() > 0)
if (p == null)
{
output.append("+");
output.append(item.getEnchantLevel());
output.append(" ");
continue;
}
output.append(", ");
if (p instanceof L2ItemInstance)
{
final L2ItemInstance item = (L2ItemInstance) p;
StringUtil.append(output, "item ", String.valueOf(item.getObjectId()), ":");
if (item.getEnchantLevel() > 0)
{
StringUtil.append(output, "+", String.valueOf(item.getEnchantLevel()), " ");
}
StringUtil.append(output, item.getItem().getName(), "(", String.valueOf(item.getCount()), ")");
}
else
{
output.append(p.toString());
}
output.append(item.getItem().getName());
output.append("(");
output.append(item.getCount());
output.append(")");
}
else
{
output.append(p);
}
}
output.append(Config.EOL);

View File

@ -16,19 +16,23 @@
*/
package com.l2jmobius.log.formatter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.StringUtil;
public class OlympiadFormatter extends AbstractFormatter
public class OlympiadFormatter extends Formatter
{
private final SimpleDateFormat dateFmt = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
@Override
public String format(LogRecord record)
{
final Object[] params = record.getParameters();
final StringBuilder output = new StringBuilder(32 + record.getMessage().length() + (params != null ? 10 * params.length : 0));
output.append(super.format(record));
final StringBuilder output = StringUtil.startAppend(30 + record.getMessage().length() + (params == null ? 0 : params.length * 10), dateFmt.format(new Date(record.getMillis())), ",", record.getMessage());
if (params != null)
{
for (Object p : params)
@ -37,11 +41,10 @@ public class OlympiadFormatter extends AbstractFormatter
{
continue;
}
output.append(",");
output.append(p);
StringUtil.append(output, ",", p.toString());
}
}
output.append(Config.EOL);
return output.toString();
}
}
}