-
Notifications
You must be signed in to change notification settings - Fork 6
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
Log.printf("Some Text: %s \n", mystring); cant print mystring when length of string >15 chars #6
Comments
Thanks - that is odd - as most of that seems to fall through on printf - a libc function. Will try to reproduce it.
Meanwhile - could you try exactly the same with
Log.printf("Logging enabled for: %s ip: %s firmware: %s \n", esp.c_str(),ip,firmware);
And with
const char * esp = "ESP32 Security Lamp”;
To confirm that that gives the same issue. And would be nice to know the version of the Arduino IDE and expressive SDK if you can find that.
Just to rule out that it is not something like a dynamic allocation of ‘esp’ going out of fashion during the call,
Dw.
|
Hi Dirk – thanks for the quick reply.
Arduino IDE version 1.8.20 & 2.0.4. Board is ESP32 Dev Module
Arduino-ESP32 version is 2.06
Using const char * esp = "ESP32 Security Lamp”; and Log.printf("Logging enabled for: %s ip: %s firmware: %s \n", esp.c_str(),ip,firmware); both resolve the issue
Log output using String esp = “ESP32 Security Lamp”;
Logging enabled for: P? ip: 192.168.1.36 firmware: 2.0
Best Regards
Alan
From: Dirk-Willem van Gulik ***@***.***>
Date: Saturday, 11 March 2023 at 16:05
To: dirkx/tee-log ***@***.***>
Cc: alan twigg ***@***.***>, Author ***@***.***>
Subject: Re: [dirkx/tee-log] Log.printf("Some Text: %s n", mystring); cant print mystring when length of string >15 chars (Issue #6)
Thanks - that is odd - as most of that seems to fall through on printf - a libc function. Will try to reproduce it.
Meanwhile - could you try exactly the same with
Log.printf("Logging enabled for: %s ip: %s firmware: %s \n", esp.c_str(),ip,firmware);
And with
const char * esp = "ESP32 Security Lamp”;
To confirm that that gives the same issue. And would be nice to know the version of the Arduino IDE and expressive SDK if you can find that.
Just to rule out that it is not something like a dynamic allocation of ‘esp’ going out of fashion during the call,
Dw.
—
Reply to this email directly, view it on GitHub<#6 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMPY3DV6ATLQRXZIDZR4UI3W3SPEHANCNFSM6AAAAAAVXOY5KA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Ok - so the issue is either 1) something in the land of C++ where apparently the 'String mystring' pointer goes out of scope/is cleaned up to early.
Or 2) it is the case that '%s' is not the right reference for a c++ std::String (as it does not use something akin to std::print behind the scenes).
Did the compiler give you any warnings/errors about scope or similar when you switch verbose to the max ?
As to the latter - '%s' not the right reference; it may be worthwhile to ask/check if:
String foo = "some long strong"
Serial.printf("bar: %s and so on %d, etc\n", foo, 123);
is supposed to be correct on the ArduinoIDE mailing list. As in C++ you'd expect 'print' with '{}' to be used instead.
Now tee-log does not see/handle any of this -- the printf, println, etc are all provided by the Print class of arduino:
class LOGBase : public Print {
at https://github.com/dirkx/tee-log/blob/225afed6041594b10f20ffe1dc87733333c843d9/src/TLog.h#L48. So I am not quite sure how to fix this in tee-log.
|
Thanks for your help, Dirk, %s is the correct string formatter, for printf . Arduino doesn’t have a Serial.printf function, I’m happy to use esp.c_str() instead of String esp. –
I agree I don’t think it’s a tee-log issue.
Please consider the issue closed.
Thanks
Alan
From: Dirk-Willem van Gulik ***@***.***>
Date: Sunday, 12 March 2023 at 13:09
To: dirkx/tee-log ***@***.***>
Cc: alan twigg ***@***.***>, Author ***@***.***>
Subject: Re: [dirkx/tee-log] Log.printf("Some Text: %s n", mystring); cant print mystring when length of string >15 chars (Issue #6)
Ok - so the issue is either 1) something in the land of C++ where apparently the 'String mystring' pointer goes out of scope/is cleaned up to early.
Or 2) it is the case that '%s' is not the right reference for a c++ std::String (as it does not use something akin to std::print behind the scenes).
Did the compiler give you any warnings/errors about scope or similar when you switch verbose to the max ?
As to the latter - '%s' not the right reference; it may be worthwhile to ask/check if:
String foo = "some long strong"
Serial.printf("bar: %s and so on %d, etc\n", foo, 123);
is supposed to be correct on the ArduinoIDE mailing list. As in C++ you'd expect 'print' with '{}' to be used instead.
Now tee-log does not see/handle any of this -- the printf, println, etc are all provided by the Print class of arduino:
class LOGBase : public Print {
at https://github.com/dirkx/tee-log/blob/225afed6041594b10f20ffe1dc87733333c843d9/src/TLog.h#L48. So I am not quite sure how to fix this in tee-log.
—
Reply to this email directly, view it on GitHub<#6 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AMPY3DQTTAVVA2EIQNMUOO3W3XDIJANCNFSM6AAAAAAVXOY5KA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
#closed
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug, issue or concern
// Logging
#include <SyslogStream.h>
#include <TLog.h>
#define SYSLOGHOST "192.XXX.1.245"
SyslogStream syslogStream = SyslogStream();
String esp = "ESP32 Security Lamp";
void logSetup() {
syslogStream.setDestination(SYSLOGHOST);
syslogStream.setRaw(true); // wether or not the syslog server is a modern(ish) unix.
syslogStream.setPort(514);
const std::shared_ptr syslogStreamPtr = std::make_shared(syslogStream);
Log.addPrintStream(syslogStreamPtr);
Log.begin();
Log.printf("Logging enabled for: %s ip: %s firmware: %s \n", esp,ip,firmware);
}
To Reproduce
esp is a literal string , when the string exceeds 15 chars a '?' is printed in the log
The text was updated successfully, but these errors were encountered: