log just info to info.log

This commit is contained in:
mcinj 2022-05-13 12:34:56 -04:00
parent ceb55bec68
commit d250ed48b5
4 changed files with 32 additions and 10 deletions

View file

@ -1,3 +1,4 @@
config/config.ini config/config.ini
config/debug.log config/debug.log
config/sqlite.db config/sqlite.db
config/info.log

2
.gitignore vendored
View file

@ -4,5 +4,5 @@ venv/
__pycache__/ __pycache__/
.idea .idea
config/config.ini config/config.ini
config/debug.log config/*.log*
config/sqlite.db config/sqlite.db

View file

@ -9,13 +9,33 @@ logging.basicConfig(
level=logging.DEBUG, level=logging.DEBUG,
format=log_format) format=log_format)
stream = logging.StreamHandler() console_output = logging.StreamHandler()
stream.setLevel(logging.INFO) console_output.setLevel(logging.INFO)
stream_format = logging.Formatter(log_format) console_format = logging.Formatter(log_format)
stream.setFormatter(stream_format) console_output.setFormatter(console_format)
info_log_file = RotatingFileHandler('../config/info.log', maxBytes=500000, backupCount=10)
info_log_file.setLevel(logging.INFO)
info_log_format = logging.Formatter(log_format)
info_log_file.setFormatter(info_log_format)
logging.root.addHandler(console_output)
logging.root.addHandler(info_log_file)
logging.info("""
-------------------------------------------------------------------------------------
_____ _ _ __ _ ____ _
/ ____|| | (_) / _|| | | _ \ | |
| (___ | |_ ___ __ _ _ __ ___ __ _ _ | |_ | |_ ___ | |_) | ___ | |_
\___ \ | __|/ _ \ / _` || '_ ` _ \ / _` || || _|| __|/ __| | _ < / _ \ | __|
____) || |_| __/| (_| || | | | | || (_| || || | | |_ \__ \ | |_) || (_) || |_
|_____/ \__|\___| \__,_||_| |_| |_| \__, ||_||_| \__||___/ |____/ \___/ \__|
__/ |
|___/
-------------------------------------------------------------------------------------
""")
def get_logger(name): def get_logger(name):
l = logging.getLogger(name) l = logging.getLogger(name)
l.addHandler(stream)
return l return l

View file

@ -11,6 +11,7 @@ logger = log.get_logger(__name__)
def run(): def run():
logger.info("Starting Steamgifts bot.")
file_name = '../config/config.ini' file_name = '../config/config.ini'
config = None config = None
try: try: