migrate Logging Features

This commit is contained in:
deathbybandaid 2019-05-04 16:57:32 -04:00
parent 1882582a9a
commit e7c7cc87e4
14 changed files with 39 additions and 43 deletions

View File

@ -6,7 +6,7 @@ Sopel BotEvents is a poor mans way to create module load order dependencies
from __future__ import unicode_literals, absolute_import, division, print_function
import sopel.module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_SBTools import bot_logging
import threading

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals, absolute_import, division, print_function
import sopel.module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_SBTools import bot_logging
from .BotEvents import set_bot_event, check_bot_startup

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# sopel imports
import sopel.module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel.config.types import StaticSection, ValidatedAttribute, ListAttribute
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, startup_bot_event
@ -15,7 +14,8 @@ import spicemanip
from sopel_modules.SpiceBot_SBTools import (
sopel_triggerargs, inlist, topic_compile, channel_privs,
join_all_channels, chanadmin_all_channels, channel_list_current
join_all_channels, chanadmin_all_channels, channel_list_current,
bot_logging
)

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel
import sopel.module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
import os
from difflib import SequenceMatcher
@ -12,7 +11,7 @@ from operator import itemgetter
import threading
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, check_bot_events
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, check_bot_events, bot_logging
import spicemanip

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# sopel imports
import sopel.module
from sopel.tools import Identifier
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_SBTools import bot_logging
from sopel.db import _deserialize, SopelDB
import json

View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# sopel imports
import sopel.module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_SBTools import bot_logging
def setup(bot):

View File

@ -3,14 +3,13 @@
from __future__ import unicode_literals, absolute_import, division, print_function
import sopel.module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel.config.types import StaticSection, ValidatedAttribute
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, startup_bot_event
from sopel_modules.SpiceBot_CommandsQuery.CommandsQuery import commandsquery_register, commandsquery_register_type
from sopel_modules.SpiceBot_SBTools import read_directory_json_to_dict, sopel_triggerargs
from sopel_modules.SpiceBot_SBTools import read_directory_json_to_dict, sopel_triggerargs, bot_logging
import spicemanip

View File

@ -69,26 +69,3 @@ def bot_command_action(bot, trigger):
bot.osd("Is Examining " + str(logtype) + " log(s).")
for line in bot.memory['SpiceBot_Logs'][logtype]:
bot.osd(str(line), trigger.sender, 'action')
def bot_logging(bot, logtype, logentry):
if 'SpiceBot_Logs_queue' not in bot.memory:
bot.memory['SpiceBot_Logs_queue'] = []
logmessage = "[" + logtype + "] " + logentry
if bot.config.SpiceBot_Logs.logging_channel:
bot.memory['SpiceBot_Logs_queue'].append(logmessage)
stderr(logmessage)
if 'SpiceBot_Logs' not in bot.memory:
bot.memory['SpiceBot_Logs'] = {}
if logtype not in bot.memory['SpiceBot_Logs'].keys():
bot.memory['SpiceBot_Logs'][logtype] = []
bot.memory['SpiceBot_Logs'][logtype].append(logentry)
if len(bot.memory['SpiceBot_Logs'][logtype]) > 10:
del bot.memory['SpiceBot_Logs'][logtype][0]

View File

@ -6,8 +6,7 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
import sopel.module
from sopel.config.types import StaticSection, ValidatedAttribute
from sopel_modules.SpiceBot_SBTools import service_manip
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_SBTools import service_manip, bot_logging
@sopel.module.nickname_commands('restart')

View File

@ -7,8 +7,6 @@ import sopel
from sopel.module import OP, ADMIN, VOICE, OWNER, HALFOP
HOP = HALFOP
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
import collections
import re
import os
@ -88,6 +86,32 @@ def command_permissions_check(bot, trigger, privslist):
return True
"""Logging"""
def bot_logging(bot, logtype, logentry):
if 'SpiceBot_Logs_queue' not in bot.memory:
bot.memory['SpiceBot_Logs_queue'] = []
logmessage = "[" + logtype + "] " + logentry
if bot.config.SpiceBot_Logs.logging_channel:
bot.memory['SpiceBot_Logs_queue'].append(logmessage)
stderr(logmessage)
if 'SpiceBot_Logs' not in bot.memory:
bot.memory['SpiceBot_Logs'] = {}
if logtype not in bot.memory['SpiceBot_Logs'].keys():
bot.memory['SpiceBot_Logs'][logtype] = []
bot.memory['SpiceBot_Logs'][logtype].append(logentry)
if len(bot.memory['SpiceBot_Logs'][logtype]) > 10:
del bot.memory['SpiceBot_Logs'][logtype][0]
"""
Time
"""

View File

@ -3,11 +3,10 @@
from __future__ import unicode_literals, absolute_import, division, print_function
from sopel import module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_Botevents.BotEvents import set_bot_event, check_bot_events
from sopel_modules.SpiceBot_SBTools import humanized_time
from sopel_modules.SpiceBot_SBTools import humanized_time, bot_logging
import time

View File

@ -4,14 +4,13 @@ from __future__ import unicode_literals, absolute_import, print_function, divisi
# sopel imports
import sopel.module
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel.config.types import StaticSection, ValidatedAttribute
import os
import spicemanip
from sopel_modules.SpiceBot_SBTools import service_manip, sopel_triggerargs, command_permissions_check
from sopel_modules.SpiceBot_SBTools import service_manip, sopel_triggerargs, command_permissions_check, bot_logging
class SpiceBot_Update_MainSection(StaticSection):

View File

@ -8,7 +8,7 @@ import time
from sopel_modules.SpiceBot_SBTools import humanized_time
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_SBTools import bot_logging
def configure(config):

View File

@ -14,7 +14,7 @@ from sopel import tools, module
from sopel.tools import Identifier
from sopel.config.types import StaticSection, ValidatedAttribute
from sopel_modules.SpiceBot_Logs.Logs import bot_logging
from sopel_modules.SpiceBot_SBTools import bot_logging
import time
from collections import abc