Comments (3)
The way I think we handle this is by providing an F() macro in the base logger, which is defined if there isn't one defined in the logging strategy. This would ensure that logger code doesn't have to change.
We would need a derived strategy which handles F() appropriately, needs to read the string from flash. We can't put this in the base necessarily because we might want to use the logger with unit tests that don't include Arduino.h/WString.h. We should allow swapping to a strategy which just passes these strings through if there's no overriding implementation.
One implication, however, is that the F() macro must be included/defined by the Arduino headers before including the base logger header.
from arduino-logger.
https://www.arduino.cc/reference/en/language/variables/utilities/progmem/
https://www.nongnu.org/avr-libc/user-manual/pgmspace.html
from arduino-logger.
size_t Print::print(const __FlashStringHelper *ifsh) {
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
char buff[128] __attribute__ ((aligned(4)));
auto len = strlen_P(p);
size_t n = 0;
while (n < len) {
int to_write = std::min(sizeof(buff), len - n);
memcpy_P(buff, p, to_write);
auto written = write(buff, to_write);
n += written;
p += written;
if (!written) {
// Some error, write() should write at least 1 byte before returning
break;
}
}
return n;
}
from arduino-logger.
Related Issues (20)
- Test with Arduino 1.5 HOT 2
- Expand rotational SD logger support HOT 1
- Improve compile-time Filtering
- Check support for filtering message levels & routing differently HOT 1
- Rotational SD Logger: Add an option for placing a cap on log file size
- Rotational SD Logger: Add option to configure number of log files
- Add Meson Documentation
- Redesign to eliminate macros HOT 1
- Error : 'SdFs' has not been declared HOT 2
- Improve Checks for Flushing and Overrun
- Add doxygen documentation for LoggerBase HOT 1
- Unable to clone project HOT 3
- Rebrand Library OR Extract non-Arduino logging core into another library HOT 2
- Create SD file logger strategy example HOT 1
- Timestamp support HOT 1
- Add a TRACE macro
- Rebrand library HOT 1
- Create examples showing TRACE(), FUNC(), and PRETTYFUNC() HOT 1
- Create a log disable strategy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino-logger.