Logging
Logger class is used to print message for information and debugging purpose. FigNet Supports serilog as default logger.
File logging can be enabled from ServerConfig.xml it will log into a text file instead of console. Logs output dir is logs/filename.txt at root level of Application.
Interface
namespace FigNet.Core
{
public interface ILogger
{
void Error(string info);
void Error(string info, params object[] args);
void Exception(Exception exception, string info);
void Exception(Exception exception, string info, params object[] args);
void Info(string info);
void Info(string info, params object[] args);
void SetUp(bool enableFileLogging, string fileName);
void Warning(string info);
void Warning(string info, params object[] args);
}
}
Usage
FN.Logger.Info("Hello FigNet");
Logging Level
FigNet provider following logging level that can be set or changed from ServerConfig.xml using LoggingLevel tag
<LoggingLevel>INFO</LoggingLevel> <!--NONE, INFO, DEBUG, ALL-->
Levels
Description
NONE
disable logging
INFO
print log messages as-is with timestep only
DEBUG
INFO + log info of data sent and received over network that includes Message Id, IsEncrypted, CallbackId, DeliveryMode, ChannelId, Message Size
ALL
DEBUG + log content of the message as hex code
Example of Logging level set to DEBUG
[13:31:26 INF] Received<= MessageId : 10 | IsEncrypted False | CallbackId 2 | SenderId 0 | MessageSize 12
[13:31:27 INF] Send=> MessageId : 10 | IsEncrypted False | CallbackId 2 | SendingTo 0 | DeliveryMode ReliableOrdered | ChannelId 0 | MessageSize 79
Example of Logging level set to ALL
[13:34:35 INF] Received<= MessageId : 10 |IsEncrypted False | CallbackId 2 | SenderId 0 | MessageSize 12 Message Content: ED-E1-3D-79-0A-00-02-91-81-00-CC-01
[13:34:35 INF] Send=> MessageId : 10 | IsEncrypted False | CallbackId 2 | SendingTo 0 | DeliveryMode ReliableOrdered | ChannelId 0 | MessageSize 79 Message Content: 48-B6-DD-D3-0A-00-02-91-81-00-D9-43-44-6F-6E-E2-80-99-74-20-79-6F-75-20-68-61-74-65-20-69-74-20-77-68-65-6E-20-73-6F-6D-65-6F-6E-65-20-61-6E-73-77-65-72-73-20-74-68-65-69-72-20-6F-77-6E-20-71-75-65-73-74-69-6F-6E-73-3F-20-49-20-64-6F-2E
Helper Methods
During troubleshooting when logging level is set to ALL, the logs become overwhelmed due to the amount of data being logs. FigNet provides helper methods that can be used to subscribe to particular messages only at runtime. If not message is subscribed then logger will print info for all network message else it will print logs of subscribed message only
// Note: These methods applies when Logging Level is set to ALL
// FN.SubscribeToDetailedLog(10);
public static void SubscribeToDetailedLog(ushort messageId);
public static void UnSubscribeToDetailedLog(ushort messageId);
Or add SubscribeDebugMessages node in Configuration file
<SubscribeDebugMessages>
<MessageInfo>
<Id>10</Id>
</MessageInfo>
<MessageInfo>
<Id>5</Id>
</MessageInfo>
<!--here add more messageInfos-->
</SubscribeDebugMessages>
On Unity side when logging level is set to all Add button will appear add message Ids as needed

Last updated
Was this helpful?