standalone-lights & logging & more #35

Merged
alex_orid merged 14 commits from standalone-lights into v2.0 2021-04-28 07:33:08 +00:00
4 changed files with 51 additions and 7 deletions
Showing only changes of commit f34e53fe1f - Show all commits

View File

@ -2,31 +2,43 @@ version: '3.7'
services:
standalone_command:
image: standalone_command
volumes:
- c:/praxis/logs
ports:
- 6009:6009
environment:
- ISDOCKER=cat
standalone_channelrewards:
image: standalone_channelrewards
volumes:
- c:/praxis/logs
ports:
- 6969:6969
environment:
- ISDOCKER=cat
standalone_lights:
image: standalone_lights
volumes:
- c:/praxis/logs
ports:
- 42069:42069
environment:
- ISDOCKER=cat
standalone_twitchscript:
image: standalone_twitchscript
volumes:
- c:/praxis/logs
environment:
- ISDOCKER=cat
standalone_twitch_pubsub:
image: standalone_twitch_pubsub
volumes:
- c:/praxis/logs
environment:
- ISDOCKER=cat
standalone_discordscript:
image: standalone_discordscript
volumes:
- c:/praxis/logs
environment:
- ISDOCKER=cat

View File

@ -0,0 +1,12 @@
INFO:root:Application running!
INFO:root:
-Starting Logs: standalone_channelrewards.py
INFO:root:init stuff
INFO:werkzeug: * Restarting with stat
INFO:root:Application running!
INFO:root:
-Starting Logs: standalone_channelrewards.py
INFO:root:init stuff
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 760-498-562
INFO:werkzeug: * Running on http://0.0.0.0:6969/ (Press CTRL+C to quit)

14
praxis_logging.py Normal file
View File

@ -0,0 +1,14 @@
import logging
import utilities_script
class praxis_logger():
def init(self, name):
super().__init__()
self.logName = "logs/" + name + ".log"
utilities_script.get_dir("logs")
logging.basicConfig(filename=self.logName, level=logging.DEBUG)
logging.info('Application running!')
def log(self, msg):
print(self.logName, msg)
logging.info(msg)

View File

@ -4,6 +4,12 @@ from flask import request
import channel_rewards.channelRewards_loader as rewards_loader
from channel_rewards.channelRewards_base import AbstractChannelRewards
import os
import praxis_logging
praxis_logger_obj = praxis_logging.praxis_logger()
praxis_logger_obj.init(os.path.basename(__file__))
praxis_logger_obj.log("\n -Starting Logs: " + os.path.basename(__file__))
api = flask.Flask(__name__)
# enable/disable this to get web pages of crashes returned
api.config["DEBUG"] = True
@ -12,7 +18,7 @@ loadedRewards = {}
def init():
# todo load entire reward library and cache it here
print("init stuff")
praxis_logger_obj.log("init stuff")
loadedRewards[AbstractChannelRewards.ChannelRewardsType.channelPoints] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.channelPoints)
loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_bits] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_bits)
loadedRewards[AbstractChannelRewards.ChannelRewardsType.twitch_subs] = rewards_loader.load_rewards(AbstractChannelRewards.ChannelRewardsType.twitch_subs)
@ -22,12 +28,12 @@ def is_reward(reward_name, reward_type) -> bool:
#global loadedRewards
tempType = reward_type.replace('ChannelRewardsType.', '')
realTempType = AbstractChannelRewards.ChannelRewardsType.__dict__[tempType]
#print(loadedRewards[realTempType])
#praxis_logger_obj.log(loadedRewards[realTempType])
for reward in loadedRewards[realTempType]:
print("found: ", reward, "type: ", type(reward))
praxis_logger_obj.log("found: ", reward, "type: ", type(reward))
if reward_name == reward:
print("Equal")
praxis_logger_obj.log("Equal")
return True
@ -48,15 +54,15 @@ def handle_reward(source, username, reward_name, reward_type, rewardPrompt, user
return flask.make_response("{\"message\":\"%s\"}" % reward_response, 200, {"Content-Type": "application/json"})
except:
return "None"
#print("Doing a reward")
#praxis_logger_obj.log("Doing a reward")
@api.route('/api/v1/reward', methods=['GET'])
def reward_check():
if 'reward_name' in request.args and 'reward_type' in request.args:
print("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type'])
praxis_logger_obj.log("reward_name:", request.args['reward_name'],"reward_type:", request.args['reward_type'])
if is_reward(request.args['reward_name'], request.args['reward_type']):
print("about to send")
praxis_logger_obj.log("about to send")
return flask.make_response('', 200)
else:
return flask.make_response('', 404)