-
Notifications
You must be signed in to change notification settings - Fork 56
IntelliJ Logging Management
Our current logging system supports:
- Only one log file for the whole plugin.
- Single line log entries.
Important notes:
- There is no need to put logs in tests.
- It is very important that exceptions thrown during the plugin's run appear in the log file, therefore you should add a log entry in catch clauses.
The logging system consists of these three classes:Logger
, LogFileUtils
and BasicLogEntry
.
The main class of our logging system is Logger
. There are currently four levels of logging (from high to low):
-
Debug
- includes debugging information, infos, warnings and errors. -
Info
- includes infos, warnings and errors. -
Warn
- includes warnings and errors. -
Error
- includes only errors.
Currently the default level is Info
.
This class saves the wanted logging level and logs only events of lower or equal level, for example if the logger's level is Info
then events of level Debug
will be ignored.
The LogFileUtils
class supplies utils for editing, probing, and creating our log files at low level.
This class's main purpose is to actually perform the action of writing into the log file.
The BasicLogEntry
class represents a log entry. This is the smallest unit the logger uses and it is what will be printed to the log file.
It is very easy to use the logging system in your class, in order to do that you should follow the next steps:
- There should be a static member of type
Logger
in your class. This member will be initialized with your class'sClass
object. - In order to change the level of logging (as explained above) use the method
setLogLevel
. - To add a log entry you will need to use the appropriate method for the type of the entry:
debug
,info
,warn
,error
. You can check the full API of theLogger
class here. Notice that entries of higher level than the one set to the logger will be ignored.
An example of usage can be found here.