Ok, just for absolute clarity, here's what I'd like the Log Engine to be capable of.
First off, I'd like to build Categories of logging events:
Database
Network
Client
Spawn
Item
NPC
Spells
Quest
Market
Common
Server
Command
etc...
That is the MAJOR categories for logging something. If you turn on or off a Category at this level, ALL logging types for that category are either on or off (see below for an example).
Secondly, I'd like each CATEGORY to be expandable to however we need logging to be broken out in detail. Let's take Database, again.
Database, Message
Database, Error
Database, Query
Database, Result
Database, Trace
Each one of these can be either on or off, individually... with a default set by us as recommended settings (in case log_config.xml is missing).
A sample log_config.xml entry might be:
Code: Select all
<LogConfig Category="Database" Type="Error" Enabled="1" Output="2" Color="FF0000" />
This is an entry to tell the logging system to output Database, Errors to both the log file only (bitwise=2) with a color of
RED (Color is
optional, as we will set default colors in the code - this tag is only here to allow customization).
This sample log_config.xml shows how you can set the Category to output (or not) every possible database log Type in 1 line:
Code: Select all
<LogConfig Category="Database" Enabled="1" Output="3" />
Notice Type is not defined. That means, output the entire category to the console -and- file (bitwise=3) using the default color.
And yes, Color only effects the console screen, not the Text Log files
A more complete example might be:
Code: Select all
<LogConfig Category="Database" Type="Message" Enabled="0" Output="1" />
<LogConfig Category="Database" Type="Error" Enabled="1" Output="3" Color="934BAC" />
<LogConfig Category="Database" Type="Query" Enabled="0" Output="1" />
<LogConfig Category="Database" Type="Result" Enabled="0" Output="1" />
<LogConfig Category="Database" Type="Trace" Enabled="0" Output="1" />
<LogConfig Category="Network" Type="Error" Enabled="1" Output="3" />
<LogConfig Category="Network" Type="Debug" Enabled="0" Output="1" />
<LogConfig Category="Network" Type="Packet_Trace" Enabled="0" Output="1" />
<LogConfig Category="Network" Type="Packet_Error" Enabled="1" Output="3" />
<LogConfig Category="Network" Type="Op_Error" Enabled="1" Output="3" />
<LogConfig Category="Spawn" Type="Error" Enabled="1" Output="3" />
<LogConfig Category="Spawn" Type="Warning" Enabled="0" Output="1" />
<LogConfig Category="Spawn" Type="Message" Enabled="0" Output="3" />
<LogConfig Category="Spawn" Type="Pop" Enabled="0" Output="1" />
<LogConfig Category="Spawn" Type="Depop" Enabled="0" Output="1" />
<LogConfig Category="Item" Enabled="1" Output="3" />
Here you see Database, Network, Spawn all configured to the Type level, with Item being on globally for all possible defined Item-type logging, outputting to the console and file. Note the COLOR setting only on Database, Error because I happen to be testing something today that I want to stand out in the logs.
Note: Your log_config.xml can have NOTHING in it, or missing entirely, and the Log System will still output our pre-defined log items.
- In the C++ Code, the logging would be initiated with this type of command line:
Code: Select all
if(query.GetErrorNumber() && query.GetErrorNumber() < 0xFFFFFFFF){
LogWrite(DATABASE__ERROR, "Error in query '%s': %s", query.GetQuery(), query.GetError());
}
...and on the Logging engine side, it knows that A) this is a Database category, and B) it is specifically an ERROR log type, so output it according to defaults or config settings.
I do not feel we need:
Code: Select all
<Log ID="0">
<Setting Name="Error" />
<Setting On="true" />
<Setting Color="red" />
</Log>
<Log ID="1">
<Setting Name="Debug" />
<Setting On="true" />
<Setting Color="white" />
</Log>
<Log ID="2">
<Setting Name="Warning" />
<Setting On="true" />
<Setting Color="yellow" />
</Log>
<Log ID="3">
<Setting Name="Status" />
<Setting On="true" />
<Setting Color="white" />
</Log>
since we'll be controlling not only enabled/disabled and color from each individual config entry, but I did not want to hard-code
Error, Debug, Warning, Status as our only possible options to log things with. Ie., that's why I wanted "Types", so we can easily make new types up as needed.
Anyway, please discuss if this makes no sense.