From ed0a0a58f7346b830bae36b263ef8d77cef1e905 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Tue, 14 Jun 2016 05:09:30 +0100 Subject: [PATCH] added nlog logging (todo: custom logger for packets) --- .../FFXIVClassic Common Class Lib.csproj | 4 +- FFXIVClassic Common Class Lib/Log.cs | 136 - FFXIVClassic Common Class Lib/packages.config | 4 + FFXIVClassic Lobby Server/ClientConnection.cs | 2 +- FFXIVClassic Lobby Server/ConfigConstants.cs | 8 +- FFXIVClassic Lobby Server/Database.cs | 8 +- .../FFXIVClassic Lobby Server.csproj | 10 + FFXIVClassic Lobby Server/NLog.config | 45 + FFXIVClassic Lobby Server/NLog.xsd | 2601 +++++++++++++++++ FFXIVClassic Lobby Server/PacketProcessor.cs | 32 +- FFXIVClassic Lobby Server/Program.cs | 23 +- FFXIVClassic Lobby Server/Server.cs | 13 +- FFXIVClassic Lobby Server/packages.config | 15 +- .../packets/BasePacket.cs | 2 +- .../packets/SubPacket.cs | 12 +- FFXIVClassic Map Server/ClientConnection.cs | 2 +- FFXIVClassic Map Server/CommandProcessor.cs | 8 +- FFXIVClassic Map Server/ConfigConstants.cs | 8 +- FFXIVClassic Map Server/Database.cs | 2 +- .../FFXIVClassic Map Server.csproj | 10 + FFXIVClassic Map Server/NLog.config | 45 + FFXIVClassic Map Server/NLog.xsd | 2601 +++++++++++++++++ FFXIVClassic Map Server/PacketProcessor.cs | 14 +- FFXIVClassic Map Server/Program.cs | 35 +- FFXIVClassic Map Server/Server.cs | 15 +- FFXIVClassic Map Server/WorldManager.cs | 8 +- .../actors/StaticActors.cs | 2 +- .../actors/chara/player/Player.cs | 2 +- FFXIVClassic Map Server/actors/quest/Quest.cs | 4 +- FFXIVClassic Map Server/lua/LuaEngine.cs | 2 +- FFXIVClassic Map Server/packages.config | 17 +- FFXIVClassic Map Server/packets/BasePacket.cs | 2 +- FFXIVClassic Map Server/packets/SubPacket.cs | 6 +- .../utils/SQLGeneration.cs | 8 +- data/lobby_config.ini | 17 - data/map_config.ini | 17 - 36 files changed, 5430 insertions(+), 310 deletions(-) delete mode 100644 FFXIVClassic Common Class Lib/Log.cs create mode 100644 FFXIVClassic Common Class Lib/packages.config create mode 100644 FFXIVClassic Lobby Server/NLog.config create mode 100644 FFXIVClassic Lobby Server/NLog.xsd create mode 100644 FFXIVClassic Map Server/NLog.config create mode 100644 FFXIVClassic Map Server/NLog.xsd diff --git a/FFXIVClassic Common Class Lib/FFXIVClassic Common Class Lib.csproj b/FFXIVClassic Common Class Lib/FFXIVClassic Common Class Lib.csproj index e096cebc..1adbda3e 100644 --- a/FFXIVClassic Common Class Lib/FFXIVClassic Common Class Lib.csproj +++ b/FFXIVClassic Common Class Lib/FFXIVClassic Common Class Lib.csproj @@ -48,11 +48,13 @@ - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FFXIVClassic Lobby Server/NLog.xsd b/FFXIVClassic Lobby Server/NLog.xsd new file mode 100644 index 00000000..175dd774 --- /dev/null +++ b/FFXIVClassic Lobby Server/NLog.xsd @@ -0,0 +1,2601 @@ + + + + + + + + + + + + + + + Watch config file for changes and reload automatically. + + + + + Print internal NLog messages to the console. Default value is: false + + + + + Print internal NLog messages to the console error output. Default value is: false + + + + + Write internal NLog messages to the specified file. + + + + + Log level threshold for internal log messages. Default value is: Info. + + + + + Global log level threshold for application log messages. Messages below this level won't be logged.. + + + + + Pass NLog internal exceptions to the application. Default value is: false. + + + + + Write internal NLog messages to the the System.Diagnostics.Trace. Default value is: false + + + + + + + + + + + + + + Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). + + + + + + + + + + + + + + + + + Prefix for targets/layout renderers/filters/conditions loaded from this assembly. + + + + + Load NLog extensions from the specified file (*.dll) + + + + + Load NLog extensions from the specified assembly. Assembly name should be fully qualified. + + + + + + + + + + Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name* + + + + + Comma separated list of levels that this rule matches. + + + + + Minimum level that this rule matches. + + + + + Maximum level that this rule matches. + + + + + Level that this rule matches. + + + + + Comma separated list of target names. + + + + + Ignore further rules if this one matches. + + + + + Enable or disable logging rule. Disabled rules are ignored. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the file to be included. The name is relative to the name of the current config file. + + + + + Ignore any errors in the include file. + + + + + + + Variable name. + + + + + Variable value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to add <!-- --> comments around all written texts. + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events that should be processed in a batch by the lazy writer thread. + + + + + Action to be taken when the lazy writer thread request queue count exceeds the set limit. + + + + + Limit on the number of requests in the lazy writer thread request queue. + + + + + Time in milliseconds to sleep between batches. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events to be buffered. + + + + + Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. + + + + + Indicates whether to use sliding timeout. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the will be more connections than . + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Maximum current connections. 0 = no maximum. + + + + + Network address. + + + + + Maximum queue size. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Viewer parameter name. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to use default row highlighting rules. + + + + + The encoding for writing messages to the . + + + + + Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Condition that must be met in order to set the specified foreground and background color. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + + Indicates whether to ignore case when comparing texts. + + + + + Regular expression to be matched. You must specify either text or regex. + + + + + Text to be matched. You must specify either text or regex. + + + + + Indicates whether to match whole words only. + + + + + Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send the log messages to the standard error instead of the standard output. + + + + + The encoding for writing messages to the . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + + + + + Name of the connection string (as specified in <connectionStrings> configuration section. + + + + + Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. + + + + + Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. + + + + + Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. + + + + + Name of the database provider. + + + + + Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. + + + + + Indicates whether to keep the database connection open between the log events. + + + + + Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this. + + + + + Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. + + + + + Text of the SQL command to be run on each log level. + + + + + Type of the SQL command to be run on each log level. + + + + + + + + + + + + + + + + + + + + + + + Type of the command. + + + + + Connection string to run the command against. If not provided, connection string from the target is used. + + + + + Indicates whether to ignore failures. + + + + + Command text. + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Database parameter name. + + + + + Database parameter precision. + + + + + Database parameter scale. + + + + + Database parameter size. + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Layout that renders event Category. + + + + + Layout that renders event ID. + + + + + Name of the Event Log to write to. This can be System, Application or any user-defined name. + + + + + Name of the machine on which Event Log service is running. + + + + + Value to be used as the event Source. + + + + + Action to take if the message is larger than the option. + + + + + Optional entrytype. When not set, or when not convertable to then determined by + + + + + Message length limit to write to the Event Log. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether to return to the first target after any successful write. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + File encoding. + + + + + Line ending mode. + + + + + Way file archives are numbered. + + + + + Name of the file to be used for an archive. + + + + + Indicates whether to automatically archive log files every time the specified time passes. + + + + + Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose: + + + + + Maximum number of archive files that should be kept. + + + + + Indicates whether to compress archive files into the zip archive format. + + + + + Gets or set a value indicating whether a managed file stream is forced, instead of used the native implementation. + + + + + Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. + + + + + Name of the file to write to. + + + + + Value specifying the date format to use when archiving files. + + + + + Indicates whether to archive old log file on startup. + + + + + Indicates whether to create directories if they do not exist. + + + + + Indicates whether to enable log file(s) to be deleted. + + + + + File attributes (Windows only). + + + + + Indicates whether to delete old log file on startup. + + + + + Indicates whether to replace file contents on each write instead of appending log message at the end. + + + + + Indicates whether concurrent writes to the log file by multiple processes on the same host. + + + + + Delay in milliseconds to wait before attempting to write to the file again. + + + + + Maximum number of log filenames that should be stored as existing. + + + + + Indicates whether concurrent writes to the log file by multiple processes on different network hosts. + + + + + Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). + + + + + Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. + + + + + Log file buffer size in bytes. + + + + + Indicates whether to automatically flush the file buffers after each log message. + + + + + Number of times the write is appended on the file before NLog discards the log message. + + + + + Indicates whether to keep log file open instead of opening and closing it on each logging event. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Condition expression. Log events who meet this condition will be forwarded to the wrapped target. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Windows domain name to change context to. + + + + + Required impersonation level. + + + + + Type of the logon provider. + + + + + Logon Type. + + + + + User account password. + + + + + Indicates whether to revert to the credentials of the process instead of impersonating another user. + + + + + Username to change context to. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Endpoint address. + + + + + Name of the endpoint configuration in WCF configuration file. + + + + + Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply) + + + + + Client ID. + + + + + Indicates whether to include per-event properties in the payload sent to the server. + + + + + Indicates whether to use binary message encoding. + + + + + + + + + + + + + + Layout that should be use to calculate the value for the parameter. + + + + + Name of the parameter. + + + + + Type of the parameter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send message as HTML instead of plain text. + + + + + Encoding to be used for sending e-mail. + + + + + Indicates whether to add new lines between log entries. + + + + + CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Mail message body (repeated for each log message send in one mail). + + + + + Mail subject. + + + + + Sender's email address (e.g. joe@domain.com). + + + + + Indicates whether NewLine characters in the body should be replaced with tags. + + + + + Priority used for sending mails. + + + + + Indicates the SMTP client timeout. + + + + + SMTP Server to be used for sending. + + + + + SMTP Authentication mode. + + + + + Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. + + + + + Port number that SMTP Server is listening on. + + + + + Indicates whether the default Settings from System.Net.MailSettings should be used. + + + + + Folder where applications save mail messages to be processed by the local SMTP server. + + + + + Specifies how outgoing email messages will be handled. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used when writing text to the queue. + + + + + Indicates whether to use the XML format when serializing message. This will also disable creating queues. + + + + + Indicates whether to check if a queue exists before writing to it. + + + + + Indicates whether to create the queue if it doesn't exists. + + + + + Label to associate with each message. + + + + + Name of the queue to write to. + + + + + Indicates whether to use recoverable messages (with guaranteed delivery). + + + + + + + + + + + + + + + + + Name of the target. + + + + + Class name. + + + + + Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the will be more connections than . + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Network address. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum current connections. 0 = no maximum. + + + + + Maximum queue size. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the will be more connections than . + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Maximum current connections. 0 = no maximum. + + + + + Network address. + + + + + Maximum queue size. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to perform layout calculation. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether performance counter should be automatically created. + + + + + Name of the performance counter category. + + + + + Counter help text. + + + + + Name of the performance counter. + + + + + Performance counter type. + + + + + The value by which to increment the counter. + + + + + Performance counter instance name. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Default filter to be applied when no specific rule matches. + + + + + + + + + + + + + Condition to be tested. + + + + + Resulting filter to be applied when the condition matches. + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Number of times to repeat each log message. + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of retries that should be attempted on the wrapped target in case of a failure. + + + + + Time to wait between retries in milliseconds. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. + + + + + Encoding. + + + + + Web service method name. Only used with Soap. + + + + + Web service namespace. Only used with Soap. + + + + + Protocol to be used when calling web service. + + + + + Web service URL. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). + + + + + Column delimiter. + + + + + Quote Character. + + + + + Quoting mode. + + + + + Indicates whether CVS should include header. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Layout of the column. + + + + + Name of the column. + + + + + + + + + + + + + Option to suppress the extra spaces in the output json + + + + + + + + + + + + + + Determines wether or not this attribute will be Json encoded. + + + + + Layout that will be rendered as the attribute's value. + + + + + Name of the attribute. + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + + + + + + + + + + + + + + + + + Layout text. + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Condition expression. + + + + + + + + + + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FFXIVClassic Lobby Server/PacketProcessor.cs b/FFXIVClassic Lobby Server/PacketProcessor.cs index 4adc7d10..c7c723f9 100644 --- a/FFXIVClassic Lobby Server/PacketProcessor.cs +++ b/FFXIVClassic Lobby Server/PacketProcessor.cs @@ -53,7 +53,7 @@ namespace FFXIVClassic_Lobby_Server case 0x0F: //Mod Retainers default: - Program.Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode)); + Program.Log.Debug("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode); break; } } @@ -67,7 +67,7 @@ namespace FFXIVClassic_Lobby_Server byte[] blowfishKey = GenerateKey(securityHandshake.ticketPhrase, securityHandshake.clientNumber); client.blowfish = new Blowfish(blowfishKey); - Program.Log.Info(String.Format("SecCNum: 0x{0:X}", securityHandshake.clientNumber)); + Program.Log.Info("SecCNum: 0x{0:X}", securityHandshake.clientNumber); //Respond with acknowledgment BasePacket outgoingPacket = new BasePacket(HardCoded_Packets.g_secureConnectionAcknowledgment); @@ -81,8 +81,8 @@ namespace FFXIVClassic_Lobby_Server SessionPacket sessionPacket = new SessionPacket(packet.data); String clientVersion = sessionPacket.version; - Program.Log.Info(String.Format("Got acknowledgment for secure session.")); - Program.Log.Info(String.Format("CLIENT VERSION: {0}", clientVersion)); + Program.Log.Info("Got acknowledgment for secure session."); + Program.Log.Info("CLIENT VERSION: {0}", clientVersion); uint userId = Database.getUserIdFromSession(sessionPacket.session); client.currentUserId = userId; @@ -96,11 +96,11 @@ namespace FFXIVClassic_Lobby_Server BasePacket.encryptPacket(client.blowfish, errorBasePacket); client.queuePacket(errorBasePacket); - Program.Log.Info(String.Format("Invalid session, kicking...")); + Program.Log.Info("Invalid session, kicking..."); return; } - Program.Log.Info(String.Format("USER ID: {0}", userId)); + Program.Log.Info("USER ID: {0}", userId); List accountList = new List(); Account defaultAccount = new Account(); @@ -115,7 +115,7 @@ namespace FFXIVClassic_Lobby_Server private void ProcessGetCharacters(ClientConnection client, SubPacket packet) { - Program.Log.Info(String.Format("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId)); + Program.Log.Info("{0} => Get characters", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId); sendWorldList(client, packet); sendImportList(client, packet); @@ -128,7 +128,7 @@ namespace FFXIVClassic_Lobby_Server { SelectCharacterPacket selectCharRequest = new SelectCharacterPacket(packet.data); - Program.Log.Info(String.Format("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, selectCharRequest.characterId)); + Program.Log.Info("{0} => Select character id {1}", client.currentUserId == 0 ? client.getAddress() : "User " + client.currentUserId, selectCharRequest.characterId); Character chara = Database.getCharacter(client.currentUserId, selectCharRequest.characterId); World world = null; @@ -187,7 +187,7 @@ namespace FFXIVClassic_Lobby_Server BasePacket.encryptPacket(client.blowfish, basePacket); client.queuePacket(basePacket); - Program.Log.Info(String.Format("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId)); + Program.Log.Info("User {0} => Error; invalid server id: \"{1}\"", client.currentUserId, worldId); return; } @@ -207,7 +207,7 @@ namespace FFXIVClassic_Lobby_Server BasePacket.encryptPacket(client.blowfish, basePacket); client.queuePacket(basePacket); - Program.Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName)); + Program.Log.Info("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName); return; } else @@ -219,7 +219,7 @@ namespace FFXIVClassic_Lobby_Server client.newCharaName = name; } - Program.Log.Info(String.Format("User {0} => Character reserved \"{1}\"", client.currentUserId, name)); + Program.Log.Info("User {0} => Character reserved \"{1}\"", client.currentUserId, name); break; case 0x02://Make CharaInfo info = CharaInfo.getFromNewCharRequest(charaReq.characterInfoEncoded); @@ -272,7 +272,7 @@ namespace FFXIVClassic_Lobby_Server cid = client.newCharaCid; name = client.newCharaName; - Program.Log.Info(String.Format("User {0} => Character created \"{1}\"", client.currentUserId, name)); + Program.Log.Info("User {0} => Character created \"{1}\"", client.currentUserId, name); break; case 0x03://Rename @@ -286,20 +286,20 @@ namespace FFXIVClassic_Lobby_Server BasePacket.encryptPacket(client.blowfish, basePacket); client.queuePacket(basePacket); - Program.Log.Info(String.Format("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName)); + Program.Log.Info("User {0} => Error; name taken: \"{1}\"", client.currentUserId, charaReq.characterName); return; } - Program.Log.Info(String.Format("User {0} => Character renamed \"{1}\"", client.currentUserId, name)); + Program.Log.Info("User {0} => Character renamed \"{1}\"", client.currentUserId, name); break; case 0x04://Delete Database.deleteCharacter(charaReq.characterId, charaReq.characterName); - Program.Log.Info(String.Format("User {0} => Character deleted \"{1}\"", client.currentUserId, name)); + Program.Log.Info("User {0} => Character deleted \"{1}\"", client.currentUserId, name); break; case 0x06://Rename Retainer - Program.Log.Info(String.Format("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name)); + Program.Log.Info("User {0} => Retainer renamed \"{1}\"", client.currentUserId, name); break; } diff --git a/FFXIVClassic Lobby Server/Program.cs b/FFXIVClassic Lobby Server/Program.cs index 9303f30f..72ac95fc 100644 --- a/FFXIVClassic Lobby Server/Program.cs +++ b/FFXIVClassic Lobby Server/Program.cs @@ -4,12 +4,12 @@ using System.Threading; using MySql.Data.MySqlClient; using System.Reflection; using FFXIVClassic.Common; - +using NLog; namespace FFXIVClassic_Lobby_Server { class Program { - public static Log Log; + public static Logger Log; static void Main(string[] args) { @@ -24,20 +24,7 @@ namespace FFXIVClassic_Lobby_Server if (!ConfigConstants.load()) startServer = false; - Log = new Log(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE, Int32.Parse(ConfigConstants.OPTIONS_LOGLEVEL)); - - Thread thread = new Thread(() => - { - while (true) - { - if (Log.LogQueue.Count > 0) - { - var message = Program.Log.LogQueue.Dequeue(); - Program.Log.WriteMessage(message.Item1, message.Item2); - } - } - }); - thread.Start(); + Log = LogManager.GetCurrentClassLogger(); Program.Log.Info("--------FFXIV 1.0 Lobby Server--------"); @@ -47,7 +34,7 @@ namespace FFXIVClassic_Lobby_Server Program.Log.Info("Version: " + vers.ToString()); //Test DB Connection - Program.Log.Info(String.Format("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST)); + Program.Log.Info("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST); using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD))) { try @@ -55,7 +42,7 @@ namespace FFXIVClassic_Lobby_Server conn.Open(); conn.Close(); - Program.Log.Status("[OK]"); + Program.Log.Info("[OK]"); } catch (MySqlException e) { diff --git a/FFXIVClassic Lobby Server/Server.cs b/FFXIVClassic Lobby Server/Server.cs index 6bcc66a5..b6eeb7a7 100644 --- a/FFXIVClassic Lobby Server/Server.cs +++ b/FFXIVClassic Lobby Server/Server.cs @@ -5,6 +5,7 @@ using System.Net.Sockets; using System.Threading; using FFXIVClassic_Lobby_Server.packets; using FFXIVClassic.Common; +using NLog; namespace FFXIVClassic_Lobby_Server { @@ -25,7 +26,7 @@ namespace FFXIVClassic_Lobby_Server private void socketCleanup() { - Program.Log.Debug(String.Format("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME)); + Program.Log.Info("Cleanup thread started; it will run every {0} seconds.", CLEANUP_THREAD_SLEEP_TIME); while (!killCleanupThread) { int count = 0; @@ -40,7 +41,7 @@ namespace FFXIVClassic_Lobby_Server } } if (count != 0) - Program.Log.Status(String.Format("{0} connections were cleaned up.", count)); + Program.Log.Info("{0} connections were cleaned up.", count); Thread.Sleep(CLEANUP_THREAD_SLEEP_TIME*1000); } } @@ -80,7 +81,7 @@ namespace FFXIVClassic_Lobby_Server } Console.ForegroundColor = ConsoleColor.White; - Program.Log.Debug(String.Format("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port)); + Program.Log.Debug("Lobby Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port); Console.ForegroundColor = ConsoleColor.Gray; mProcessor = new PacketProcessor(); @@ -105,7 +106,7 @@ namespace FFXIVClassic_Lobby_Server conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn); //Queue the accept of the next incomming connection mServerSocket.BeginAccept(new AsyncCallback(acceptCallback), mServerSocket); - Program.Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port)); + Program.Log.Info("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port); } catch (SocketException) { @@ -179,7 +180,7 @@ namespace FFXIVClassic_Lobby_Server } else { - Program.Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId)); + Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId); lock (mConnectionList) { @@ -192,7 +193,7 @@ namespace FFXIVClassic_Lobby_Server { if (conn.socket != null) { - Program.Log.Status(String.Format("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId)); + Program.Log.Info("{0} has disconnected.", conn.currentUserId == 0 ? conn.getAddress() : "User " + conn.currentUserId); lock (mConnectionList) { diff --git a/FFXIVClassic Lobby Server/packages.config b/FFXIVClassic Lobby Server/packages.config index 1fb7142b..5a3427bf 100644 --- a/FFXIVClassic Lobby Server/packages.config +++ b/FFXIVClassic Lobby Server/packages.config @@ -1,7 +1,10 @@ - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/FFXIVClassic Lobby Server/packets/BasePacket.cs b/FFXIVClassic Lobby Server/packets/BasePacket.cs index 956af8ee..587acd36 100644 --- a/FFXIVClassic Lobby Server/packets/BasePacket.cs +++ b/FFXIVClassic Lobby Server/packets/BasePacket.cs @@ -336,7 +336,7 @@ namespace FFXIVClassic_Lobby_Server.packets #if DEBUG Console.BackgroundColor = ConsoleColor.DarkYellow; - Program.Log.Debug(String.Format("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + Program.Log.Debug("IsAuth: {0} Size: 0x{1:X}, NumSubpackets: {2}{3}{4}", header.isAuthenticated, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())); foreach (SubPacket sub in getSubpackets()) { diff --git a/FFXIVClassic Lobby Server/packets/SubPacket.cs b/FFXIVClassic Lobby Server/packets/SubPacket.cs index c9263b19..bdf8e9e9 100644 --- a/FFXIVClassic Lobby Server/packets/SubPacket.cs +++ b/FFXIVClassic Lobby Server/packets/SubPacket.cs @@ -140,20 +140,14 @@ namespace FFXIVClassic_Lobby_Server.packets public void debugPrintSubPacket() { #if DEBUG - Console.BackgroundColor = ConsoleColor.DarkRed; - - Program.Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + Program.Log.Debug("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())); if (header.type == 0x03) { - Program.Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE))); + Program.Log.Debug("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE)); } - Console.BackgroundColor = ConsoleColor.DarkMagenta; - - Program.Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE))); - - Console.BackgroundColor = ConsoleColor.Black; + Program.Log.Debug("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE)); #endif } diff --git a/FFXIVClassic Map Server/ClientConnection.cs b/FFXIVClassic Map Server/ClientConnection.cs index 67b2a04c..a06b5961 100644 --- a/FFXIVClassic Map Server/ClientConnection.cs +++ b/FFXIVClassic Map Server/ClientConnection.cs @@ -46,7 +46,7 @@ namespace FFXIVClassic_Map_Server socket.Send(packetBytes); } catch (Exception e) - { Program.Log.Error(String.Format("Weird case, socket was d/ced: {0}", e)); } + { Program.Log.Error("Weird case, socket was d/ced: {0}", e); } } } diff --git a/FFXIVClassic Map Server/CommandProcessor.cs b/FFXIVClassic Map Server/CommandProcessor.cs index 79db6b74..73bd6c5c 100644 --- a/FFXIVClassic Map Server/CommandProcessor.cs +++ b/FFXIVClassic Map Server/CommandProcessor.cs @@ -142,7 +142,7 @@ namespace FFXIVClassic_Map_Server foreach (KeyValuePair entry in mConnectedPlayerList) { Player p = entry.Value.getActor(); - Program.Log.Info(String.Format("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation)); + Program.Log.Info("{0}\'s position: ZoneID: {1}, X: {2}, Y: {3}, Z: {4}, Rotation: {5}", p.customDisplayName, p.zoneId, p.positionX, p.positionY, p.positionZ, p.rotation); } } } @@ -607,7 +607,7 @@ namespace FFXIVClassic_Map_Server { if (client != null) { - Program.Log.Info(String.Format("Got request to reset zone: {0}", client.getActor().zoneId)); + Program.Log.Info("Got request to reset zone: {0}", client.getActor().zoneId); client.getActor().zone.clear(); client.getActor().zone.addActorToZone(client.getActor()); client.getActor().sendInstanceUpdate(); @@ -621,11 +621,11 @@ namespace FFXIVClassic_Map_Server #region !reloaditems else if (split[0].Equals("reloaditems")) { - Program.Log.Info(String.Format("Got request to reload item gamedata")); + Program.Log.Info("Got request to reload item gamedata"); sendMessage(client, "Reloading Item Gamedata..."); gamedataItems.Clear(); gamedataItems = Database.getItemGamedata(); - Program.Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count)); + Program.Log.Info("Loaded {0} items.", gamedataItems.Count); sendMessage(client, String.Format("Loaded {0} items.", gamedataItems.Count)); return true; } diff --git a/FFXIVClassic Map Server/ConfigConstants.cs b/FFXIVClassic Map Server/ConfigConstants.cs index 1143c1f6..18248d2d 100644 --- a/FFXIVClassic Map Server/ConfigConstants.cs +++ b/FFXIVClassic Map Server/ConfigConstants.cs @@ -9,9 +9,6 @@ namespace FFXIVClassic_Map_Server public static String OPTIONS_BINDIP; public static String OPTIONS_PORT; public static bool OPTIONS_TIMESTAMP = false; - public static String OPTIONS_LOGPATH; - public static String OPTIONS_LOGFILE; - public static String OPTIONS_LOGLEVEL; public static uint DATABASE_WORLDID; public static String DATABASE_HOST; @@ -37,9 +34,6 @@ namespace FFXIVClassic_Map_Server ConfigConstants.OPTIONS_BINDIP = configIni.GetValue("General", "server_ip", "127.0.0.1"); ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "54992"); ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true"); - ConfigConstants.OPTIONS_LOGPATH = configIni.GetValue("General", "log_path", "./logs/"); - ConfigConstants.OPTIONS_LOGFILE = configIni.GetValue("General", "log_file_name", String.Format("map_{0}_{1}.log", OPTIONS_BINDIP, OPTIONS_PORT)); - ConfigConstants.OPTIONS_LOGLEVEL = configIni.GetValue("General", "log_level", "127"); ConfigConstants.DATABASE_WORLDID = UInt32.Parse(configIni.GetValue("Database", "worldid", "0")); ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", ""); @@ -49,7 +43,7 @@ namespace FFXIVClassic_Map_Server ConfigConstants.DATABASE_PASSWORD = configIni.GetValue("Database", "password", ""); Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine(String.Format("[OK]")); + Console.WriteLine("[OK]"); Console.ForegroundColor = ConsoleColor.Gray; return true; diff --git a/FFXIVClassic Map Server/Database.cs b/FFXIVClassic Map Server/Database.cs index d022516c..426beb47 100644 --- a/FFXIVClassic Map Server/Database.cs +++ b/FFXIVClassic Map Server/Database.cs @@ -322,7 +322,7 @@ namespace FFXIVClassic_Map_Server int slot = player.getQuestSlot(quest.actorId); if (slot == -1) { - Program.Log.Error(String.Format("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId)); + Program.Log.Error("Tried saving quest player didn't have: Player: {0:x}, QuestId: {0:x}", player.actorId, quest.actorId); return; } else diff --git a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj index 7fa0490e..d6c8b577 100644 --- a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj +++ b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj @@ -57,6 +57,10 @@ ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll True + + ..\packages\NLog.4.3.5\lib\net45\NLog.dll + True + @@ -268,6 +272,12 @@ + + Always + + + Designer + diff --git a/FFXIVClassic Map Server/NLog.config b/FFXIVClassic Map Server/NLog.config new file mode 100644 index 00000000..1d8fb2f4 --- /dev/null +++ b/FFXIVClassic Map Server/NLog.config @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FFXIVClassic Map Server/NLog.xsd b/FFXIVClassic Map Server/NLog.xsd new file mode 100644 index 00000000..175dd774 --- /dev/null +++ b/FFXIVClassic Map Server/NLog.xsd @@ -0,0 +1,2601 @@ + + + + + + + + + + + + + + + Watch config file for changes and reload automatically. + + + + + Print internal NLog messages to the console. Default value is: false + + + + + Print internal NLog messages to the console error output. Default value is: false + + + + + Write internal NLog messages to the specified file. + + + + + Log level threshold for internal log messages. Default value is: Info. + + + + + Global log level threshold for application log messages. Messages below this level won't be logged.. + + + + + Pass NLog internal exceptions to the application. Default value is: false. + + + + + Write internal NLog messages to the the System.Diagnostics.Trace. Default value is: false + + + + + + + + + + + + + + Make all targets within this section asynchronous (creates additional threads but the calling thread isn't blocked by any target writes). + + + + + + + + + + + + + + + + + Prefix for targets/layout renderers/filters/conditions loaded from this assembly. + + + + + Load NLog extensions from the specified file (*.dll) + + + + + Load NLog extensions from the specified assembly. Assembly name should be fully qualified. + + + + + + + + + + Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name* + + + + + Comma separated list of levels that this rule matches. + + + + + Minimum level that this rule matches. + + + + + Maximum level that this rule matches. + + + + + Level that this rule matches. + + + + + Comma separated list of target names. + + + + + Ignore further rules if this one matches. + + + + + Enable or disable logging rule. Disabled rules are ignored. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the file to be included. The name is relative to the name of the current config file. + + + + + Ignore any errors in the include file. + + + + + + + Variable name. + + + + + Variable value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to add <!-- --> comments around all written texts. + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events that should be processed in a batch by the lazy writer thread. + + + + + Action to be taken when the lazy writer thread request queue count exceeds the set limit. + + + + + Limit on the number of requests in the lazy writer thread request queue. + + + + + Time in milliseconds to sleep between batches. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of log events to be buffered. + + + + + Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. + + + + + Indicates whether to use sliding timeout. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the will be more connections than . + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Maximum current connections. 0 = no maximum. + + + + + Network address. + + + + + Maximum queue size. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Viewer parameter name. + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to use default row highlighting rules. + + + + + The encoding for writing messages to the . + + + + + Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Condition that must be met in order to set the specified foreground and background color. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + + Indicates whether to ignore case when comparing texts. + + + + + Regular expression to be matched. You must specify either text or regex. + + + + + Text to be matched. You must specify either text or regex. + + + + + Indicates whether to match whole words only. + + + + + Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. + + + + + Background color. + + + + + Foreground color. + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send the log messages to the standard error instead of the standard output. + + + + + The encoding for writing messages to the . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + + + + + Name of the connection string (as specified in <connectionStrings> configuration section. + + + + + Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. + + + + + Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. + + + + + Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. + + + + + Name of the database provider. + + + + + Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. + + + + + Indicates whether to keep the database connection open between the log events. + + + + + Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this. + + + + + Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. + + + + + Text of the SQL command to be run on each log level. + + + + + Type of the SQL command to be run on each log level. + + + + + + + + + + + + + + + + + + + + + + + Type of the command. + + + + + Connection string to run the command against. If not provided, connection string from the target is used. + + + + + Indicates whether to ignore failures. + + + + + Command text. + + + + + + + + + + + + + + Layout that should be use to calcuate the value for the parameter. + + + + + Database parameter name. + + + + + Database parameter precision. + + + + + Database parameter scale. + + + + + Database parameter size. + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Layout that renders event Category. + + + + + Layout that renders event ID. + + + + + Name of the Event Log to write to. This can be System, Application or any user-defined name. + + + + + Name of the machine on which Event Log service is running. + + + + + Value to be used as the event Source. + + + + + Action to take if the message is larger than the option. + + + + + Optional entrytype. When not set, or when not convertable to then determined by + + + + + Message length limit to write to the Event Log. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether to return to the first target after any successful write. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + File encoding. + + + + + Line ending mode. + + + + + Way file archives are numbered. + + + + + Name of the file to be used for an archive. + + + + + Indicates whether to automatically archive log files every time the specified time passes. + + + + + Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose: + + + + + Maximum number of archive files that should be kept. + + + + + Indicates whether to compress archive files into the zip archive format. + + + + + Gets or set a value indicating whether a managed file stream is forced, instead of used the native implementation. + + + + + Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. + + + + + Name of the file to write to. + + + + + Value specifying the date format to use when archiving files. + + + + + Indicates whether to archive old log file on startup. + + + + + Indicates whether to create directories if they do not exist. + + + + + Indicates whether to enable log file(s) to be deleted. + + + + + File attributes (Windows only). + + + + + Indicates whether to delete old log file on startup. + + + + + Indicates whether to replace file contents on each write instead of appending log message at the end. + + + + + Indicates whether concurrent writes to the log file by multiple processes on the same host. + + + + + Delay in milliseconds to wait before attempting to write to the file again. + + + + + Maximum number of log filenames that should be stored as existing. + + + + + Indicates whether concurrent writes to the log file by multiple processes on different network hosts. + + + + + Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger). + + + + + Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. + + + + + Log file buffer size in bytes. + + + + + Indicates whether to automatically flush the file buffers after each log message. + + + + + Number of times the write is appended on the file before NLog discards the log message. + + + + + Indicates whether to keep log file open instead of opening and closing it on each logging event. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Condition expression. Log events who meet this condition will be forwarded to the wrapped target. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Windows domain name to change context to. + + + + + Required impersonation level. + + + + + Type of the logon provider. + + + + + Logon Type. + + + + + User account password. + + + + + Indicates whether to revert to the credentials of the process instead of impersonating another user. + + + + + Username to change context to. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Endpoint address. + + + + + Name of the endpoint configuration in WCF configuration file. + + + + + Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply) + + + + + Client ID. + + + + + Indicates whether to include per-event properties in the payload sent to the server. + + + + + Indicates whether to use binary message encoding. + + + + + + + + + + + + + + Layout that should be use to calculate the value for the parameter. + + + + + Name of the parameter. + + + + + Type of the parameter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Indicates whether to send message as HTML instead of plain text. + + + + + Encoding to be used for sending e-mail. + + + + + Indicates whether to add new lines between log entries. + + + + + CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + + + + + Mail message body (repeated for each log message send in one mail). + + + + + Mail subject. + + + + + Sender's email address (e.g. joe@domain.com). + + + + + Indicates whether NewLine characters in the body should be replaced with tags. + + + + + Priority used for sending mails. + + + + + Indicates the SMTP client timeout. + + + + + SMTP Server to be used for sending. + + + + + SMTP Authentication mode. + + + + + Username used to connect to SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Password used to authenticate against SMTP server (used when SmtpAuthentication is set to "basic"). + + + + + Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. + + + + + Port number that SMTP Server is listening on. + + + + + Indicates whether the default Settings from System.Net.MailSettings should be used. + + + + + Folder where applications save mail messages to be processed by the local SMTP server. + + + + + Specifies how outgoing email messages will be handled. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used when writing text to the queue. + + + + + Indicates whether to use the XML format when serializing message. This will also disable creating queues. + + + + + Indicates whether to check if a queue exists before writing to it. + + + + + Indicates whether to create the queue if it doesn't exists. + + + + + Label to associate with each message. + + + + + Name of the queue to write to. + + + + + Indicates whether to use recoverable messages (with guaranteed delivery). + + + + + + + + + + + + + + + + + Name of the target. + + + + + Class name. + + + + + Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Encoding to be used. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the will be more connections than . + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Network address. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Indicates whether to keep connection open whenever possible. + + + + + Maximum current connections. 0 = no maximum. + + + + + Maximum queue size. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Encoding to be used. + + + + + Instance of that is used to format log messages. + + + + + Maximum message size in bytes. + + + + + Indicates whether to append newline at the end of log message. + + + + + Action that should be taken if the will be more connections than . + + + + + Action that should be taken if the message is larger than maxMessageSize. + + + + + Indicates whether to keep connection open whenever possible. + + + + + Size of the connection cache (number of connections which are kept alive). + + + + + Maximum current connections. 0 = no maximum. + + + + + Network address. + + + + + Maximum queue size. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + NDC item separator. + + + + + Indicates whether to include stack contents. + + + + + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + AppInfo field. By default it's the friendly name of the current AppDomain. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Indicates whether to include dictionary contents. + + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + Indicates whether to perform layout calculation. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Indicates whether performance counter should be automatically created. + + + + + Name of the performance counter category. + + + + + Counter help text. + + + + + Name of the performance counter. + + + + + Performance counter type. + + + + + The value by which to increment the counter. + + + + + Performance counter instance name. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Default filter to be applied when no specific rule matches. + + + + + + + + + + + + + Condition to be tested. + + + + + Resulting filter to be applied when the condition matches. + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Number of times to repeat each log message. + + + + + + + + + + + + + + + + Name of the target. + + + + + Number of retries that should be attempted on the wrapped target in case of a failure. + + + + + Time to wait between retries in milliseconds. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + Name of the target. + + + + + + + + + + + + + + + Name of the target. + + + + + Layout used to format log messages. + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + + + Should we include the BOM (Byte-order-mark) for UTF? Influences the property. This will only work for UTF-8. + + + + + Encoding. + + + + + Web service method name. Only used with Soap. + + + + + Web service namespace. Only used with Soap. + + + + + Protocol to be used when calling web service. + + + + + Web service URL. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). + + + + + Column delimiter. + + + + + Quote Character. + + + + + Quoting mode. + + + + + Indicates whether CVS should include header. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Layout of the column. + + + + + Name of the column. + + + + + + + + + + + + + Option to suppress the extra spaces in the output json + + + + + + + + + + + + + + Determines wether or not this attribute will be Json encoded. + + + + + Layout that will be rendered as the attribute's value. + + + + + Name of the attribute. + + + + + + + + + + + + + + Footer layout. + + + + + Header layout. + + + + + Body layout (can be repeated multiple times). + + + + + + + + + + + + + + + + + + + + + Layout text. + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Condition expression. + + + + + + + + + + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + Substring to be matched. + + + + + + + + + + + + + + + + + Action to be taken when filter matches. + + + + + String to compare the layout to. + + + + + Indicates whether to ignore case when comparing strings. + + + + + Layout to be used to filter log messages. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FFXIVClassic Map Server/PacketProcessor.cs b/FFXIVClassic Map Server/PacketProcessor.cs index 289bf720..734df6cd 100644 --- a/FFXIVClassic Map Server/PacketProcessor.cs +++ b/FFXIVClassic Map Server/PacketProcessor.cs @@ -127,9 +127,9 @@ namespace FFXIVClassic_Map_Server player.setConnection(packet.header.connectionType, client); if (packet.header.connectionType == BasePacket.TYPE_ZONE) - Program.Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress())); + Program.Log.Debug("Got {0} connection for ActorID {1} @ {2}.", "zone", actorID, client.getAddress()); else if (packet.header.connectionType == BasePacket.TYPE_CHAT) - Program.Log.Debug(String.Format("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress())); + Program.Log.Debug("Got {0} connection for ActorID {1} @ {2}.", "chat", actorID, client.getAddress()); //Create player actor reply1.debugPrintPacket(); @@ -180,7 +180,7 @@ namespace FFXIVClassic_Map_Server //Chat Received case 0x0003: ChatMessagePacket chatMessage = new ChatMessagePacket(subpacket.data); - Program.Log.Info(String.Format("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType)); + Program.Log.Info("Got type-{5} message: {0} @ {1}, {2}, {3}, Rot: {4}", chatMessage.message, chatMessage.posX, chatMessage.posY, chatMessage.posZ, chatMessage.posRot, chatMessage.logType); subpacket.debugPrintSubPacket(); if (chatMessage.message.StartsWith("!")) @@ -268,7 +268,7 @@ namespace FFXIVClassic_Map_Server ownerActor = player.getActor().currentDirector; else { - Program.Log.Debug(String.Format("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams))); + Program.Log.Debug("\n===Event START===\nCould not find actor 0x{0:X} for event started by caller: 0x{1:X}\nEvent Starter: {2}\nParams: {3}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams)); break; } } @@ -276,7 +276,7 @@ namespace FFXIVClassic_Map_Server LuaEngine.doActorOnEventStarted(player.getActor(), ownerActor, eventStart); - Program.Log.Debug(String.Format("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams))); + Program.Log.Debug("\n===Event START===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nEvent Starter: {4}\nParams: {5}", eventStart.actorID, eventStart.scriptOwnerActorID, eventStart.val1, eventStart.val2, eventStart.triggerName, LuaUtils.dumpParams(eventStart.luaParams)); break; //Unknown, happens at npc spawn and cutscene play???? case 0x00CE: @@ -285,7 +285,7 @@ namespace FFXIVClassic_Map_Server case 0x012E: subpacket.debugPrintSubPacket(); EventUpdatePacket eventUpdate = new EventUpdatePacket(subpacket.data); - Program.Log.Debug(String.Format("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.dumpParams(eventUpdate.luaParams))); + Program.Log.Debug("\n===Event UPDATE===\nSource Actor: 0x{0:X}\nCaller Actor: 0x{1:X}\nVal1: 0x{2:X}\nVal2: 0x{3:X}\nStep: 0x{4:X}\nParams: {5}", eventUpdate.actorID, eventUpdate.scriptOwnerActorID, eventUpdate.val1, eventUpdate.val2, eventUpdate.step, LuaUtils.dumpParams(eventUpdate.luaParams)); //Is it a static actor? If not look in the player's instance Actor updateOwnerActor = Server.getStaticActors(player.getActor().currentEventOwner); @@ -406,7 +406,7 @@ namespace FFXIVClassic_Map_Server client.queuePacket(BasePacket.createPacket(EndGMTicketPacket.buildPacket(player.actorID), true, false)); break; default: - Program.Log.Debug(String.Format("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode)); + Program.Log.Debug("Unknown command 0x{0:X} received.", subpacket.gameMessage.opcode); subpacket.debugPrintSubPacket(); break; } diff --git a/FFXIVClassic Map Server/Program.cs b/FFXIVClassic Map Server/Program.cs index 230ab811..80a3a6e4 100644 --- a/FFXIVClassic Map Server/Program.cs +++ b/FFXIVClassic Map Server/Program.cs @@ -1,16 +1,21 @@ using System; using System.Diagnostics; using System.Threading; +using System.Text; using MySql.Data.MySqlClient; using System.Reflection; using FFXIVClassic_Map_Server.dataobjects; using FFXIVClassic.Common; +using NLog; +using NLog.Targets; +using NLog.Targets.Wrappers; +using NLog.Config; namespace FFXIVClassic_Map_Server { class Program { - public static Log Log; + public static Logger Log; static void Main(string[] args) { @@ -22,22 +27,11 @@ namespace FFXIVClassic_Map_Server //Load Config if (!ConfigConstants.load()) - startServer = false; - - Log = new Log(ConfigConstants.OPTIONS_LOGPATH, ConfigConstants.OPTIONS_LOGFILE, Int32.Parse(ConfigConstants.OPTIONS_LOGLEVEL)); - - Thread thread = new Thread(() => - { - while (true) - { - if (Log.LogQueue.Count > 0) - { - var message = Program.Log.LogQueue.Dequeue(); - Program.Log.WriteMessage(message.Item1, message.Item2); - } - } - }); - thread.Start(); + startServer = false; + + // set up logging + + Log = LogManager.GetCurrentClassLogger(); Program.Log.Info("---------FFXIV 1.0 Map Server---------"); @@ -54,7 +48,7 @@ namespace FFXIVClassic_Map_Server conn.Open(); conn.Close(); - Program.Log.Status("[OK]"); + Program.Log.Info("[OK]"); } catch (MySqlException e) { @@ -66,7 +60,7 @@ namespace FFXIVClassic_Map_Server //Check World ID DBWorld thisWorld = Database.getServer(ConfigConstants.DATABASE_WORLDID); if (thisWorld != null) - Program.Log.Info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name)); + Program.Log.Info("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name); else Program.Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed."); @@ -77,9 +71,10 @@ namespace FFXIVClassic_Map_Server CommandProcessor cp = new CommandProcessor(server.getConnectedPlayerList()); server.startServer(); - while (true) + while (startServer) { String input = Console.ReadLine(); + Log.Info("[Console Input] " + input); cp.doCommand(input, null); } } diff --git a/FFXIVClassic Map Server/Server.cs b/FFXIVClassic Map Server/Server.cs index 597de32b..5bcac0de 100644 --- a/FFXIVClassic Map Server/Server.cs +++ b/FFXIVClassic Map Server/Server.cs @@ -6,6 +6,7 @@ using System.Threading; using FFXIVClassic_Map_Server.dataobjects; using FFXIVClassic_Map_Server.packets; using FFXIVClassic.Common; +using NLog; using FFXIVClassic_Map_Server.Actors; using FFXIVClassic_Map_Server.lua; @@ -39,7 +40,7 @@ namespace FFXIVClassic_Map_Server private void connectionHealth() { - Program.Log.Info(String.Format("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME)); + Program.Log.Info("Connection Health thread started; it will run every {0} seconds.", HEALTH_THREAD_SLEEP_TIME); while (!killHealthThread) { lock (mConnectedPlayerList) @@ -77,7 +78,7 @@ namespace FFXIVClassic_Map_Server mStaticActors = new StaticActors(STATIC_ACTORS_PATH); gamedataItems = Database.getItemGamedata(); - Program.Log.Info(String.Format("Loaded {0} items.", gamedataItems.Count)); + Program.Log.Info("Loaded {0} items.", gamedataItems.Count); mWorldManager = new WorldManager(this); mWorldManager.LoadZoneList(); @@ -113,7 +114,7 @@ namespace FFXIVClassic_Map_Server } Console.ForegroundColor = ConsoleColor.White; - Program.Log.Debug(String.Format("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port)); + Program.Log.Debug("Map Server has started @ {0}:{1}", (mServerSocket.LocalEndPoint as IPEndPoint).Address, (mServerSocket.LocalEndPoint as IPEndPoint).Port); Console.ForegroundColor = ConsoleColor.Gray; mProcessor = new PacketProcessor(this, mConnectedPlayerList, mConnectionList); @@ -150,7 +151,7 @@ namespace FFXIVClassic_Map_Server mConnectionList.Add(conn); } - Program.Log.Status(String.Format("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port)); + Program.Log.Info("Connection {0}:{1} has connected.", (conn.socket.RemoteEndPoint as IPEndPoint).Address, (conn.socket.RemoteEndPoint as IPEndPoint).Port); //Queue recieving of data from the connection conn.socket.BeginReceive(conn.buffer, 0, conn.buffer.Length, SocketFlags.None, new AsyncCallback(receiveCallback), conn); //Queue the accept of the next incomming connection @@ -217,7 +218,7 @@ namespace FFXIVClassic_Map_Server mConnectionList.Remove(conn); } if (conn.connType == BasePacket.TYPE_ZONE) - Program.Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + Program.Log.Info("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner); return; } @@ -261,7 +262,7 @@ namespace FFXIVClassic_Map_Server } else { - Program.Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + Program.Log.Info("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner); lock (mConnectionList) { @@ -273,7 +274,7 @@ namespace FFXIVClassic_Map_Server { if (conn.socket != null) { - Program.Log.Status(String.Format("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner)); + Program.Log.Info("{0} has disconnected.", conn.owner == 0 ? conn.getAddress() : "User " + conn.owner); lock (mConnectionList) { diff --git a/FFXIVClassic Map Server/WorldManager.cs b/FFXIVClassic Map Server/WorldManager.cs index 14a72928..1353c440 100644 --- a/FFXIVClassic Map Server/WorldManager.cs +++ b/FFXIVClassic Map Server/WorldManager.cs @@ -125,7 +125,7 @@ namespace FFXIVClassic_Map_Server } } - Program.Log.Info(String.Format("Loaded {0} zones and {1} private areas.", count1, count2)); + Program.Log.Info("Loaded {0} zones and {1} private areas.", count1, count2); } public void LoadZoneEntranceList() @@ -178,7 +178,7 @@ namespace FFXIVClassic_Map_Server } } - Program.Log.Info(String.Format("Loaded {0} zone spawn locations.", count)); + Program.Log.Info("Loaded {0} zone spawn locations.", count); } public void LoadNPCs() @@ -250,7 +250,7 @@ namespace FFXIVClassic_Map_Server } } - Program.Log.Info(String.Format("Loaded {0} npc(s).", count)); + Program.Log.Info("Loaded {0} npc(s).", count); } public void LoadNPCs(uint zoneId) @@ -323,7 +323,7 @@ namespace FFXIVClassic_Map_Server } } - Program.Log.Info(String.Format("Loaded {0} npc(s).", count)); + Program.Log.Info("Loaded {0} npc(s).", count); } //Moves the actor to the new zone if exists. No packets are sent nor position changed. diff --git a/FFXIVClassic Map Server/actors/StaticActors.cs b/FFXIVClassic Map Server/actors/StaticActors.cs index 4a6e989c..8cee5340 100644 --- a/FFXIVClassic Map Server/actors/StaticActors.cs +++ b/FFXIVClassic Map Server/actors/StaticActors.cs @@ -91,7 +91,7 @@ namespace FFXIVClassic_Map_Server.Actors catch(FileNotFoundException e) { Program.Log.Error("Could not find staticactors file."); return false; } - Program.Log.Info(String.Format("Loaded {0} static actors.", mStaticActors.Count())); + Program.Log.Info("Loaded {0} static actors.", mStaticActors.Count()); return true; } diff --git a/FFXIVClassic Map Server/actors/chara/player/Player.cs b/FFXIVClassic Map Server/actors/chara/player/Player.cs index ed8052d3..340a4fb0 100644 --- a/FFXIVClassic Map Server/actors/chara/player/Player.cs +++ b/FFXIVClassic Map Server/actors/chara/player/Player.cs @@ -642,7 +642,7 @@ namespace FFXIVClassic_Map_Server.Actors Database.savePlayerPlayTime(this); Database.savePlayerPosition(this); - Program.Log.Info(String.Format("{0} has been logged out and saved.", this.customDisplayName)); + Program.Log.Info("{0} has been logged out and saved.", this.customDisplayName); } public Area getZone() diff --git a/FFXIVClassic Map Server/actors/quest/Quest.cs b/FFXIVClassic Map Server/actors/quest/Quest.cs index 26db6638..1a56a6ba 100644 --- a/FFXIVClassic Map Server/actors/quest/Quest.cs +++ b/FFXIVClassic Map Server/actors/quest/Quest.cs @@ -68,7 +68,7 @@ namespace FFXIVClassic_Map_Server.Actors { if (bitIndex >= 32) { - Program.Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); + Program.Log.Error("Tried to access bit flag >= 32 for questId: {0}", actorId); return; } @@ -86,7 +86,7 @@ namespace FFXIVClassic_Map_Server.Actors { if (bitIndex >= 32) { - Program.Log.Error(String.Format("Tried to access bit flag >= 32 for questId: {0}", actorId)); + Program.Log.Error("Tried to access bit flag >= 32 for questId: {0}", actorId); return false; } else diff --git a/FFXIVClassic Map Server/lua/LuaEngine.cs b/FFXIVClassic Map Server/lua/LuaEngine.cs index 81a26540..4e3e61d5 100644 --- a/FFXIVClassic Map Server/lua/LuaEngine.cs +++ b/FFXIVClassic Map Server/lua/LuaEngine.cs @@ -217,7 +217,7 @@ namespace FFXIVClassic_Map_Server.lua } catch(SyntaxErrorException e) { - Program.Log.Error(String.Format("LUAERROR: {0}.", e.DecoratedMessage)); + Program.Log.Error("LUAERROR: {0}.", e.DecoratedMessage); return null; } return script; diff --git a/FFXIVClassic Map Server/packages.config b/FFXIVClassic Map Server/packages.config index 382be8e1..6d8ab227 100644 --- a/FFXIVClassic Map Server/packages.config +++ b/FFXIVClassic Map Server/packages.config @@ -1,8 +1,11 @@ - - - - - - - + + + + + + + + + + \ No newline at end of file diff --git a/FFXIVClassic Map Server/packets/BasePacket.cs b/FFXIVClassic Map Server/packets/BasePacket.cs index 4c25c9f2..1def763e 100644 --- a/FFXIVClassic Map Server/packets/BasePacket.cs +++ b/FFXIVClassic Map Server/packets/BasePacket.cs @@ -334,7 +334,7 @@ namespace FFXIVClassic_Map_Server.packets #if DEBUG Console.BackgroundColor = ConsoleColor.DarkYellow; - Program.Log.Debug(String.Format("IsAuth: {0} IsEncrypted: {1}, Size: 0x{2:X}, NumSubpackets: {3}{4}{5}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + Program.Log.Debug("IsAuth: {0} IsEncrypted: {1}, Size: 0x{2:X}, NumSubpackets: {3}{4}{5}", header.isAuthenticated, header.isCompressed, header.packetSize, header.numSubpackets, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())); foreach (SubPacket sub in getSubpackets()) { diff --git a/FFXIVClassic Map Server/packets/SubPacket.cs b/FFXIVClassic Map Server/packets/SubPacket.cs index 2e4530e1..da285388 100644 --- a/FFXIVClassic Map Server/packets/SubPacket.cs +++ b/FFXIVClassic Map Server/packets/SubPacket.cs @@ -142,15 +142,15 @@ namespace FFXIVClassic_Map_Server.packets #if DEBUG Console.BackgroundColor = ConsoleColor.DarkRed; - Program.Log.Debug(String.Format("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes()))); + Program.Log.Debug("Size: 0x{0:X}{1}{2}", header.subpacketSize, Environment.NewLine, Utils.ByteArrayToHex(getHeaderBytes())); if (header.type == 0x03) { - Program.Log.Debug(String.Format("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE))); + Program.Log.Debug("Opcode: 0x{0:X}{1}{2}", gameMessage.opcode, Environment.NewLine, Utils.ByteArrayToHex(getGameMessageBytes(), SUBPACKET_SIZE)); Console.BackgroundColor = ConsoleColor.DarkMagenta; - Program.Log.Debug(String.Format("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE))); + Program.Log.Debug("Data: {0}{1}", Environment.NewLine, Utils.ByteArrayToHex(data, SUBPACKET_SIZE + GAMEMESSAGE_SIZE)); } Console.BackgroundColor = ConsoleColor.Black; diff --git a/FFXIVClassic Map Server/utils/SQLGeneration.cs b/FFXIVClassic Map Server/utils/SQLGeneration.cs index d216d858..c50f3650 100644 --- a/FFXIVClassic Map Server/utils/SQLGeneration.cs +++ b/FFXIVClassic Map Server/utils/SQLGeneration.cs @@ -79,7 +79,7 @@ namespace FFXIVClassic_Map_Server.utils cmd.Parameters["@placename"].Value = placenames[pId]; - Program.Log.Debug(String.Format("Wrote: {0}", id)); + Program.Log.Debug("Wrote: {0}", id); cmd.ExecuteNonQuery(); } @@ -137,7 +137,7 @@ namespace FFXIVClassic_Map_Server.utils cmd.Parameters["@id"].Value = id; cmd.Parameters["@displayNameId"].Value = nameId; - Program.Log.Debug(String.Format("Wrote: {0} : {1}", id, nameId)); + Program.Log.Debug("Wrote: {0} : {1}", id, nameId); cmd.ExecuteNonQuery(); } @@ -203,7 +203,7 @@ namespace FFXIVClassic_Map_Server.utils cmd.Parameters["@id"].Value = id; - Program.Log.Debug(String.Format("Wrote: {0}", id)); + Program.Log.Debug("Wrote: {0}", id); cmd.ExecuteNonQuery(); } @@ -288,7 +288,7 @@ namespace FFXIVClassic_Map_Server.utils else if (id == 1500) otherId = SetCompletedAchievementsPacket.CATEGORY_GRAND_COMPANY; - Program.Log.Debug(String.Format("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points)); + Program.Log.Debug("Wrote: {0} : {1} : {2} : {3}", id, name, otherId, points); cmd.Parameters["@id"].Value = id; cmd.Parameters["@name"].Value = name; cmd.Parameters["@otherId"].Value = otherId; diff --git a/data/lobby_config.ini b/data/lobby_config.ini index 50a3f8bd..f8aa676b 100644 --- a/data/lobby_config.ini +++ b/data/lobby_config.ini @@ -2,23 +2,6 @@ server_ip=127.0.0.1 showtimestamp = true -# log_level: add up values for types you want to enable -# then convert hex -> dec and set log_level = value -# 0x000 None, -# 0x001 Console, -# 0x002 File, -# 0x004 Status, -# 0x008 Sql, -# 0x010 Info, -# 0x020 Debug, -# 0x040 Error, - -log_level = 127 - -#log_path = ./logs/ -#log_file = lobby.log - - [Database] worldid=1 host=127.0.0.1 diff --git a/data/map_config.ini b/data/map_config.ini index b5b8c243..f8aa676b 100644 --- a/data/map_config.ini +++ b/data/map_config.ini @@ -2,23 +2,6 @@ server_ip=127.0.0.1 showtimestamp = true -# log_level: add up values for types you want to enable -# then convert hex -> dec and set log_level = value -# 0x000 None, -# 0x001 Console, -# 0x002 File, -# 0x004 Status, -# 0x008 Sql, -# 0x010 Info, -# 0x020 Debug, -# 0x040 Error, - -log_level = 127 - -#log_path = ./logs/ -#log_file = map.log - - [Database] worldid=1 host=127.0.0.1