mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2025-12-06 07:42:03 +01:00
log all in file and display errors
This commit is contained in:
parent
200c0e65fa
commit
bd6ae68ea3
|
|
@ -1,8 +1,98 @@
|
|||
18.05.2015 12:15:05 - INFO: Alarm!
|
||||
18.05.2015 12:15:05 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:15:05 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:15:05 - DEBUG: try 5/0
|
||||
18.05.2015 12:15:05 - ERROR: Error in Template Plugin
|
||||
18.05.2015 12:27:39 - INFO: Alarm!
|
||||
18.05.2015 12:27:39 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:39 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:39 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:39 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:40 - INFO: Alarm!
|
||||
18.05.2015 12:27:40 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:40 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:40 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:40 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:41 - INFO: Alarm!
|
||||
18.05.2015 12:27:41 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:41 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:41 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:41 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:42 - INFO: Alarm!
|
||||
18.05.2015 12:27:42 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:42 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:42 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:42 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:43 - INFO: Alarm!
|
||||
18.05.2015 12:27:43 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:43 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:43 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:43 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:44 - INFO: Alarm!
|
||||
18.05.2015 12:27:44 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:44 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:44 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:44 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:45 - INFO: Alarm!
|
||||
18.05.2015 12:27:45 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:45 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:45 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:45 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:46 - INFO: Alarm!
|
||||
18.05.2015 12:27:46 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:46 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:46 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:46 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:47 - INFO: Alarm!
|
||||
18.05.2015 12:27:47 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:47 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:47 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:47 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:48 - INFO: Alarm!
|
||||
18.05.2015 12:27:48 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:48 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:48 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:48 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
ZeroDivisionError: division by zero
|
||||
18.05.2015 12:27:49 - INFO: Alarm!
|
||||
18.05.2015 12:27:49 - DEBUG: Loading plugin template
|
||||
18.05.2015 12:27:49 - DEBUG: Throw Template Plugin
|
||||
18.05.2015 12:27:49 - DEBUG: try 5/0
|
||||
18.05.2015 12:27:49 - ERROR: Error in Template Plugin
|
||||
Traceback (most recent call last):
|
||||
File "./plugins\template\__init__.py", line 7, in run
|
||||
test = 5/0
|
||||
|
|
|
|||
|
|
@ -4,11 +4,29 @@
|
|||
import time
|
||||
import pluginloader
|
||||
|
||||
#create new logger
|
||||
import logging
|
||||
logging.basicConfig(filename='boswatch.log', filemode='w', level=logging.DEBUG, format='%(asctime)s - %(levelname)s: %(message)s', datefmt='%d.%m.%Y %I:%M:%S')
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
#set log string format
|
||||
formatter = logging.Formatter('%(asctime)s - %(levelname)s: %(message)s', '%d.%m.%Y %I:%M:%S')
|
||||
|
||||
#create a file loger
|
||||
fh = logging.FileHandler('boswatch.log', 'w')
|
||||
fh.setLevel(logging.DEBUG) #log level >= Debug
|
||||
fh.setFormatter(formatter)
|
||||
logger.addHandler(fh)
|
||||
|
||||
#create a display loger
|
||||
ch = logging.StreamHandler()
|
||||
ch.setLevel(logging.ERROR) #log level >= Error
|
||||
ch.setFormatter(formatter)
|
||||
logger.addHandler(ch)
|
||||
|
||||
#https://docs.python.org/2/howto/logging.html#logging-basic-tutorial
|
||||
#log levels
|
||||
#----------
|
||||
#debug - debug messages only for log
|
||||
#info - only an information
|
||||
#warning
|
||||
|
|
@ -16,6 +34,9 @@ logging.basicConfig(filename='boswatch.log', filemode='w', level=logging.DEBUG,
|
|||
#exception - error handler in try:exc: into the message
|
||||
#critical - big error, program exit
|
||||
|
||||
|
||||
|
||||
|
||||
while True:
|
||||
time.sleep(1)
|
||||
print ("Alarm!")
|
||||
|
|
|
|||
Loading…
Reference in a new issue