Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging to syslog even if disabled #16

Open
EdoFede opened this issue Mar 28, 2019 · 2 comments
Open

Logging to syslog even if disabled #16

EdoFede opened this issue Mar 28, 2019 · 2 comments

Comments

@EdoFede
Copy link

EdoFede commented Mar 28, 2019

Hi,
I saw that sdm120c continues to log stuff into syslog, despite any value is given to the parameter -d.

For example, with this successfull call:

bash-4.4# sdm120c -a 1 -b 9600 -z 10 -i -p -v -c -f -g -P N -w 10 -j 10 -d 2 -q /dev/ttyUSB0
231.80 1.91 397.90 0.90 50.00 4142535 OK
bash-4.4#

This is what I found in syslog

Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: sdm120c v1.3.5.4
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: parent: bash(5035)
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: sdm120c -a 1 -b 9600 -z 10 -i -p -v -c -f -g -P N -w 10 -j 10 -d 2 -q /dev/ttyUSB0
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 3, argc = 23, c = a, optarg = 1
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: device_address = 1
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 5, argc = 23, c = b, optarg = 9600
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: speed = 9600, count_param = 0
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 7, argc = 23, c = z, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: num_retries = 10, count_param = 0
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 8, argc = 23, c = i, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: import_flag = 1, count_param = 0
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 9, argc = 23, c = p, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: power_flag = 1, count_param = 2
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 10, argc = 23, c = v, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: volt_flag = 1, count_param = 3
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 11, argc = 23, c = c, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: current_flag = 1, count_param = 4
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 12, argc = 23, c = f, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: freq_flag = 1, count_param = 5
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 13, argc = 23, c = g, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: pf_flag = 1, count_param = 6
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 15, argc = 23, c = P, optarg = N
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: c_parity = N, count_param = 6
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 17, argc = 23, c = w, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: yLockWait = 10, count_param = 6
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 19, argc = 23, c = j, optarg = 10
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: resp_timeout = 10, count_param = 6
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 21, argc = 23, c = d, optarg = 2
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: debug_flag = 0
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: optind = 22, argc = 23, c = q, optarg = 2
Mar 28 19:27:29 2cd5e925f69d sdm120c[17870]: compact_flag = 1, count_param = 6

Same behavior with -d 0

@vashkenazy
Copy link

Hi, have you solved that problem? I have the same situation here, with a Debian 10 virtual machine.
For now I filtered (discardes) all sdm120c events in /etc/rsyslog.conf with these code before auth,authpriv. [...] lines, even if it's not a definitive solution.

if $programname == 'sdm120c' then ~
& stop

Andrea

@ehoutsma
Copy link

There is a lot of debug data in syslog before the -d 0 is being processed. If you place -d 0 at the start of the command, before -a, the debug data is disabled a lot quicker, but a better way is to alter the default behavoir.

In sdm120c.c line 101, https://github.com/gianfrdp/SDM120C/blob/master/sdm120c.c#L101 it defaults to DEBUG_STDERR and DEBUG_SYSLOG.

int debug_mask = DEBUG_STDERR | DEBUG_SYSLOG; // Default, let pass all

You can change that to debug_mask = 0; so the default is to not output anything unless you enable the debug setting.
int debug_mask = 0; // Default, no debug data

gianfrdp added a commit that referenced this issue Jan 27, 2021
Fix for issues #16, #17, #19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants