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

Add ability to specify appName on per log message #3

Open
sticilface opened this issue Feb 1, 2017 · 6 comments
Open

Add ability to specify appName on per log message #3

sticilface opened this issue Feb 1, 2017 · 6 comments
Assignees
Milestone

Comments

@sticilface
Copy link

Hi,

use senario: I have several libraries running on the same ESP, doing a variety of things. With debugging enabled I'd like to be able to send debug messages from different bit of software on the same device. so the device name is the same, but the app name is different.

Would be great to have overloads to be able to specify the log level and app name for a message.

what do you think?

@arcao
Copy link
Owner

arcao commented Feb 1, 2017

Yes it's possible to implement. There is only one problem with logf functions without pri parameter because of varargs. You cannot have defined both logf(char *, ...) and logf(char *, char *, ...).

Anyway in one of my project I call appName before log / logf methods to do same as you describe:

IPAddress ip = WiFi.localIP();
syslog.appName("network").logf(LOG_INFO, "Assigned %s.local [%u.%u.%u.%u]", DEVICE_HOSTNAME, ip[0], ip[1], ip[2], ip[3]);

Only caveats is that appName store the value for following calls of log / logf. So you have it everywhere.

@sticilface
Copy link
Author

yes. i realised that. and there is no function to fetch it, set the new one, then set it back to the old one!

@sticilface
Copy link
Author

i wonder what the most elegant solution would be. Think its worth having!

@arcao arcao changed the title add ability to specify appName on a per msg Add ability to specify appName per message Feb 2, 2017
@arcao arcao changed the title Add ability to specify appName per message Add ability to specify appName per log message Feb 2, 2017
@arcao arcao changed the title Add ability to specify appName per log message Add ability to specify appName on per log message Feb 2, 2017
@sticilface
Copy link
Author

I've come up with a method that might work. I'm going to try an roll it into my own syslog attempt for my ESPManager software. I've written a string class with derived versions myStringf and mystgingf_P with constructors that take the .... This allows you to do this:

log( "appName", myStringf_P( PSTR("Test %u"), "123" ); 
log( "appName", myStringf("Test %u", "123" ); 
log( "appName", "123" ); 

Using the right move semantics makes it efficient...

@sticilface
Copy link
Author

I've use some of your code to write my own syslog client, mainly the log mask stuff and message generation. I've given you credit for it at the top of the .h is that ok. There is no licence in the repo so I want to check? Its all none profit, open source stuff.

@sticilface
Copy link
Author

I closed this by accident. sorry.

@sticilface sticilface reopened this Mar 7, 2017
@arcao arcao self-assigned this Apr 17, 2017
@arcao arcao added this to the Version 3.0.0 milestone Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants