You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
3.9 KiB
78 lines
3.9 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>JJMumbleBot - Event Logging</title>
|
|
<link rel="stylesheet" href="https://bootswatch.com/4/darkly/bootstrap.css" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="https://duckboss.github.io/JJMumbleBot/css/content-pages.css" crossorigin="anonymous">
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
|
<script src="https://duckboss.github.io/JJMumbleBot/js/insert_html.js"></script>
|
|
</head>
|
|
<body>
|
|
<nav id="table_of_contents"></nav>
|
|
<div class="main-content">
|
|
<h2 id="logging-events">Logging Events</h2>
|
|
<p>
|
|
If you want to add custom logging to existing plugins, or custom plugins then follow the instructions below.
|
|
<br>
|
|
Logging can make it easier to debug code, keep track of bot events in the server, etc.
|
|
<br>
|
|
<b>You can optionally disable logging in your config.ini file.</b>
|
|
</p>
|
|
<h3 id="logging-features">Logging Features</h3>
|
|
<ul>
|
|
<li>There are various logging levels (<b>INFO, WARNING, CRITICAL</b>) in which each level indicates the severity
|
|
of the event. In most cases the INFO level is used to log general bot events.
|
|
</li>
|
|
<li>The logging system also supports specifying the origin of the log event. The logging origin definitions are
|
|
as follows:
|
|
<ul>
|
|
<li><code>L_GENERAL</code> = "General"<br></li>
|
|
<li><code>L_USER_PRIV</code> = "UserPrivileges"<br></li>
|
|
<li><code>L_DATABASE</code> = "Database"<br></li>
|
|
<li><code>L_COMMAND</code> = "Command"<br></li>
|
|
<li><code>L_STARTUP</code> = "StartUp"<br></li>
|
|
<li><code>L_SHUTDOWN</code> = "ShutDown"<br></li>
|
|
<li><code>L_ALIASES</code> = "Aliases"<br></li>
|
|
<li><code>L_LOGGING</code> = "Logging"<br></li>
|
|
<li><code>L_DEPENDENCIES</code> = "Dependencies"</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<h3 id="logging-steps">Logging Steps</h3>
|
|
<ol>
|
|
<li>Open the python script you wish to add logging to.</li>
|
|
<li>Add this line to the top of the file: <code>'from JJMumbleBot.lib.utils.logging_utils import log'</code><br>
|
|
Importing the logging_utils file will allow you to use the logger that is used for the entire bot.
|
|
</li>
|
|
<li>To log an event you can use: <code>'log(log_level, log_message, origin=log_origin)'</code><br>
|
|
<b>Example Usage:<br>
|
|
<pre>
|
|
log(INFO, "I logged an info event!", origin=L_GENERAL)<br>
|
|
output:
|
|
[JJMumbleBot(3.0.4).General]: I logged an info event!
|
|
|
|
log(WARNING, "I logged a warning event!", origin=L_LOGGING)<br>
|
|
output:
|
|
[JJMumbleBot(3.0.4).Logging]: I logged a warning event!
|
|
|
|
log(CRITICAL, "I logged a critical issue!", origin=L_ALIASES)<br></b>
|
|
output:
|
|
[JJMumbleBot(3.0.4).Aliases]: I logged a critical event!
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>
|
|
By default, logs are time rotated every day at midnight.<br>
|
|
The bot will store a maximum of 20 logs (20 days worth) before recycling the oldest logs.
|
|
</p>
|
|
<h4 id="example-saved-log">Example Saved Log:</h4>
|
|
<p>
|
|
<img src="https://user-images.githubusercontent.com/20238115/84191244-358c6180-aa66-11ea-9589-abb527ee4c80.png"
|
|
alt="image">
|
|
</p>
|
|
</div>
|
|
<footer></footer>
|
|
</body>
|
|
</html> |