Skip to content

Commit f4b34d2

Browse files
committed
log only to a local fine
1 parent c20ce71 commit f4b34d2

File tree

3 files changed

+14
-22
lines changed

3 files changed

+14
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dist
1212
qt.conf
1313
*.exe
1414
main.spec
15+
debug.log

logconfig.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import json
99
import logging.config
1010
import logging.handlers
11-
import getpass
1211
import threading
1312

1413

@@ -41,34 +40,27 @@
4140
"formatter": "simple",
4241
"stream": "ext://sys.stdout"
4342
},
44-
45-
"graylog_gelf": {
46-
"class": "pygelf.GelfUdpHandler",
43+
44+
"local_file_handler": {
45+
"class": "logging.handlers.RotatingFileHandler",
46+
# "class": "logging.handlers.FileHandler",
4747
"level": "DEBUG",
48-
# Obviously a DLS-specific configuration: the graylog server address and port
49-
# Use the input "Load Balanced GELF TCP" on graylog2.
50-
"host": "graylog2",#.diamond.ac.uk",# "localhost", - use locaklhost for tests
51-
"port": 12201,
52-
"debug": True,
53-
# The following custom fields will be disabled if setting this False
54-
"include_extra_fields": True,
55-
"username": getpass.getuser(),
56-
"pid": os.getpid(),
57-
"application": "BarcodeScanner",
58-
"facility": "XChem",
59-
"_version": version.VERSION
48+
"formatter": "extended",
49+
"filename": "debug.log",
50+
"maxBytes": MAXBYTES,
51+
"backupCount": BACKUPCOUNT,
52+
"encoding": ENCODING,
53+
"delay" : True
6054
},
6155

6256
},
6357
"root": {
6458
# Set the level here to be the default minimum level of log record to be produced
6559
# If you set a handler to level DEBUG you will need to set either this level
6660
"level": "DEBUG",
67-
"handlers": ["console", "graylog_gelf"]
61+
"handlers": ["local_file_handler"] #["console", "local_file_handler"]
6862
}
6963
}
70-
71-
7264
class ThreadContextFilter(logging.Filter):
7365
"""A logging context filter to add thread name and ID."""
7466

main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dls_barcode.gui.main_window import DiamondBarcodeMainWindow
2-
32
import logging
43
import logconfig
54
import sys
@@ -35,10 +34,10 @@ def main(config_file, version):
3534

3635
log = logging.getLogger(".".join([__name__]))
3736
log.info("CONFIG: " + config_file)
38-
37+
log.debug(version)
3938
app = QtWidgets.QApplication(sys.argv)
4039
config = BarcodeConfig(config_file, FileManager())
41-
ui = DiamondBarcodeMainWindow(config, version, None)
40+
ui = DiamondBarcodeMainWindow(config, 'version', None)
4241

4342

4443
ui.set_actions_triger()

0 commit comments

Comments
 (0)