Skip to content

Commit 80d0ad3

Browse files
committed
use standard logging, similar to henne49/dbus-opendtu#173
else errors from 'run' script are not logged
1 parent 860daf6 commit 80d0ad3

File tree

7 files changed

+6
-19
lines changed

7 files changed

+6
-19
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ You have to edit `config.ini`. Please note the comments there as explanation!
4343

4444
| Config value | Explanation |
4545
|-------------------- | ------------- |
46-
| Logging | set loglevel for `current.log` respectivly `/var/log/dbus-d0-smartmeter/current.log`. Possible values among others are `DEBUG`, `INFO`, `WARING` |
46+
| Logging | set loglevel for `/var/log/dbus-d0-smartmeter/current`. Possible values among others are `DEBUG`, `INFO`, `WARING` |
4747
| SignOfLiveLog | if >0, interval in minutes to give stats (= number of received correct SML-data) |
4848
| CustomName | user-friendly name for the gridmeter within the Venus web-GUI |
4949
| TimeoutInterval | if no valid data is received within this millisencods-interval, the DBUS-service-property Connected will be set to 0 |
@@ -71,7 +71,7 @@ You do not have to modify serial-starter.rules beause `service/run` stops the co
7171

7272
If you have good luck, just run `install.sh` and the gridmeter appears within the Venus-GUI.
7373

74-
`current.log` will look like this:
74+
`/var/log/dbus-d0-smartmeter/current` will look like this:
7575

7676
````
7777
2023-05-31 19:13:16,534 root INFO Starting...

dbus-d0-smartmeter.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# import normal packages
44
import logging
5-
from logging.handlers import RotatingFileHandler
65
import sys
76
import os
87
import platform
@@ -424,12 +423,7 @@ def main():
424423
logging.basicConfig( format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
425424
datefmt='%Y-%m-%d %H:%M:%S',
426425
#level=logging.DEBUG,
427-
level=config['DEFAULT']['Logging'],
428-
handlers=[
429-
#logging.FileHandler("%s/current.log" % (os.path.dirname(os.path.realpath(__file__)))),
430-
RotatingFileHandler('%s/current.log' % (os.path.dirname(os.path.realpath(__file__))), maxBytes=1000000, backupCount=3),
431-
logging.StreamHandler()
432-
])
426+
level=config['DEFAULT']['Logging'])
433427

434428
try:
435429
logging.info("Starting...");

install.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ SERVICE_NAME=$(basename $SCRIPT_DIR)
55

66
# set permissions for script files
77
chmod a+x $SCRIPT_DIR/restart.sh
8-
chmod 744 $SCRIPT_DIR/restart.sh
9-
108
chmod a+x $SCRIPT_DIR/uninstall.sh
11-
chmod 744 $SCRIPT_DIR/uninstall.sh
12-
139
chmod a+x $SCRIPT_DIR/service/run
14-
chmod 755 $SCRIPT_DIR/service/run
10+
chmod a+x $SCRIPT_DIR/service/log/run
1511

1612
# create sym-link to run script in deamon
1713
ln -s $SCRIPT_DIR/service /service/$SERVICE_NAME

restart.sh

100644100755
File mode changed.

service/log/run

100644100755
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
#!/bin/sh
2-
#set -x
3-
SCRIPT_DIR=$( realpath $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) )
4-
SERVICE_NAME=$( basename $( realpath $SCRIPT_DIR/../.. ) )
52
exec 2>&1
6-
exec multilog t s25000 n4 /var/log/$SERVICE_NAME
3+
exec multilog t s25000 n4 /var/log/dbus-d0-smartmeter

service/run

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#set -x
44

55
##_
6-
DEV='/dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0'
6+
DEV='/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0'
77

88
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
99
SERVICE_NAME=$( basename $(realpath $SCRIPT_DIR/.. ) )

uninstall.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)