log just info to info.log
This commit is contained in:
parent
ceb55bec68
commit
d250ed48b5
4 changed files with 32 additions and 10 deletions
|
@ -1,3 +1,4 @@
|
|||
config/config.ini
|
||||
config/debug.log
|
||||
config/sqlite.db
|
||||
config/sqlite.db
|
||||
config/info.log
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,5 +4,5 @@ venv/
|
|||
__pycache__/
|
||||
.idea
|
||||
config/config.ini
|
||||
config/debug.log
|
||||
config/*.log*
|
||||
config/sqlite.db
|
36
src/log.py
36
src/log.py
|
@ -5,17 +5,37 @@ from logging.handlers import RotatingFileHandler
|
|||
|
||||
log_format = "%(levelname)s %(asctime)s - %(message)s"
|
||||
logging.basicConfig(
|
||||
handlers=[RotatingFileHandler('../config/debug.log', maxBytes=500000, backupCount=10)],
|
||||
level=logging.DEBUG,
|
||||
format=log_format)
|
||||
handlers=[RotatingFileHandler('../config/debug.log', maxBytes=500000, backupCount=10)],
|
||||
level=logging.DEBUG,
|
||||
format=log_format)
|
||||
|
||||
stream = logging.StreamHandler()
|
||||
stream.setLevel(logging.INFO)
|
||||
stream_format = logging.Formatter(log_format)
|
||||
stream.setFormatter(stream_format)
|
||||
console_output = logging.StreamHandler()
|
||||
console_output.setLevel(logging.INFO)
|
||||
console_format = logging.Formatter(log_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):
|
||||
l = logging.getLogger(name)
|
||||
l.addHandler(stream)
|
||||
return l
|
||||
|
|
|
@ -11,6 +11,7 @@ logger = log.get_logger(__name__)
|
|||
|
||||
|
||||
def run():
|
||||
logger.info("Starting Steamgifts bot.")
|
||||
file_name = '../config/config.ini'
|
||||
config = None
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue