mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 18:56:38 +00:00
Berry tasmota.loglevel()
and tasmota.rtc_utc()
for faster performance (#19152)
This commit is contained in:
parent
91f15d228b
commit
2a3690b866
@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
- Berry `_class` can be used in `static var` initialization code (#19088)
|
- Berry `_class` can be used in `static var` initialization code (#19088)
|
||||||
- Berry add `energy.update_total()` to call `EnergyUpdateTotal()` from energy driver
|
- Berry add `energy.update_total()` to call `EnergyUpdateTotal()` from energy driver
|
||||||
- Berry add metrics for memory allocation/deallocation/reallocation
|
- Berry add metrics for memory allocation/deallocation/reallocation
|
||||||
|
- Berry `tasmota.loglevel()` and `tasmota.rtc_utc()` for faster performance
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ extern int l_getoption(bvm *vm);
|
|||||||
extern int l_millis(bvm *vm);
|
extern int l_millis(bvm *vm);
|
||||||
extern int l_timereached(bvm *vm);
|
extern int l_timereached(bvm *vm);
|
||||||
extern int l_rtc(bvm *vm);
|
extern int l_rtc(bvm *vm);
|
||||||
|
extern int l_rtc_utc(bvm *vm);
|
||||||
extern int l_time_dump(bvm *vm);
|
extern int l_time_dump(bvm *vm);
|
||||||
extern int l_strftime(bvm *vm);
|
extern int l_strftime(bvm *vm);
|
||||||
extern int l_strptime(bvm *vm);
|
extern int l_strptime(bvm *vm);
|
||||||
@ -33,6 +34,7 @@ extern int l_delay(bvm *vm);
|
|||||||
extern int l_delay_microseconds(bvm *vm);
|
extern int l_delay_microseconds(bvm *vm);
|
||||||
extern int l_scaleuint(bvm *vm);
|
extern int l_scaleuint(bvm *vm);
|
||||||
extern int l_logInfo(bvm *vm);
|
extern int l_logInfo(bvm *vm);
|
||||||
|
extern int l_loglevel(bvm *vm);
|
||||||
extern int l_save(bvm *vm);
|
extern int l_save(bvm *vm);
|
||||||
extern int t_random_byte(bvm *vm);
|
extern int t_random_byte(bvm *vm);
|
||||||
extern int l_locale(bvm *vm);
|
extern int l_locale(bvm *vm);
|
||||||
@ -99,6 +101,7 @@ class be_class_tasmota (scope: global, name: Tasmota) {
|
|||||||
millis, func(l_millis)
|
millis, func(l_millis)
|
||||||
time_reached, func(l_timereached)
|
time_reached, func(l_timereached)
|
||||||
rtc, func(l_rtc)
|
rtc, func(l_rtc)
|
||||||
|
rtc_utc, func(l_rtc_utc)
|
||||||
time_dump, func(l_time_dump)
|
time_dump, func(l_time_dump)
|
||||||
strftime, func(l_strftime)
|
strftime, func(l_strftime)
|
||||||
strptime, func(l_strptime)
|
strptime, func(l_strptime)
|
||||||
@ -111,6 +114,7 @@ class be_class_tasmota (scope: global, name: Tasmota) {
|
|||||||
delay_microseconds, func(l_delay_microseconds)
|
delay_microseconds, func(l_delay_microseconds)
|
||||||
scale_uint, func(l_scaleuint)
|
scale_uint, func(l_scaleuint)
|
||||||
log, func(l_logInfo)
|
log, func(l_logInfo)
|
||||||
|
loglevel, func(l_loglevel)
|
||||||
save, func(l_save)
|
save, func(l_save)
|
||||||
locale, func(l_locale)
|
locale, func(l_locale)
|
||||||
|
|
||||||
|
@ -2478,13 +2478,18 @@ void AddLogData(uint32_t loglevel, const char* log_data, const char* log_data_pa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddLog(uint32_t loglevel, PGM_P formatP, ...) {
|
uint32_t HighestLogLevel() {
|
||||||
uint32_t highest_loglevel = TasmotaGlobal.seriallog_level;
|
uint32_t highest_loglevel = TasmotaGlobal.seriallog_level;
|
||||||
if (Settings->weblog_level > highest_loglevel) { highest_loglevel = Settings->weblog_level; }
|
if (Settings->weblog_level > highest_loglevel) { highest_loglevel = Settings->weblog_level; }
|
||||||
if (Settings->mqttlog_level > highest_loglevel) { highest_loglevel = Settings->mqttlog_level; }
|
if (Settings->mqttlog_level > highest_loglevel) { highest_loglevel = Settings->mqttlog_level; }
|
||||||
if (TasmotaGlobal.syslog_level > highest_loglevel) { highest_loglevel = TasmotaGlobal.syslog_level; }
|
if (TasmotaGlobal.syslog_level > highest_loglevel) { highest_loglevel = TasmotaGlobal.syslog_level; }
|
||||||
if (TasmotaGlobal.templog_level > highest_loglevel) { highest_loglevel = TasmotaGlobal.templog_level; }
|
if (TasmotaGlobal.templog_level > highest_loglevel) { highest_loglevel = TasmotaGlobal.templog_level; }
|
||||||
if (TasmotaGlobal.uptime < 3) { highest_loglevel = LOG_LEVEL_DEBUG_MORE; } // Log all before setup correct log level
|
if (TasmotaGlobal.uptime < 3) { highest_loglevel = LOG_LEVEL_DEBUG_MORE; } // Log all before setup correct log level
|
||||||
|
return highest_loglevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddLog(uint32_t loglevel, PGM_P formatP, ...) {
|
||||||
|
uint32_t highest_loglevel = HighestLogLevel();
|
||||||
|
|
||||||
// If no logging is requested then do not access heap to fight fragmentation
|
// If no logging is requested then do not access heap to fight fragmentation
|
||||||
if ((loglevel <= highest_loglevel) && (TasmotaGlobal.masterlog_level <= highest_loglevel)) {
|
if ((loglevel <= highest_loglevel) && (TasmotaGlobal.masterlog_level <= highest_loglevel)) {
|
||||||
|
@ -183,6 +183,14 @@ extern "C" {
|
|||||||
be_raise(vm, kTypeError, nullptr);
|
be_raise(vm, kTypeError, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Berry: tasmota.rtc_utc() -> int
|
||||||
|
//
|
||||||
|
int32_t l_rtc_utc(struct bvm *vm);
|
||||||
|
int32_t l_rtc_utc(struct bvm *vm) {
|
||||||
|
be_pushint(vm, Rtc.utc_time);
|
||||||
|
be_return(vm);
|
||||||
|
}
|
||||||
|
|
||||||
// Berry: tasmota.memory() -> map
|
// Berry: tasmota.memory() -> map
|
||||||
//
|
//
|
||||||
int32_t l_memory(struct bvm *vm);
|
int32_t l_memory(struct bvm *vm);
|
||||||
@ -790,6 +798,23 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
// Berry: `loglevel() -> int`
|
||||||
|
// or
|
||||||
|
// Berry: `loglevel(int) -> bool`
|
||||||
|
// return the highest log level currently in place
|
||||||
|
int32_t l_loglevel(struct bvm *vm);
|
||||||
|
int32_t l_loglevel(struct bvm *vm) {
|
||||||
|
int32_t top = be_top(vm); // Get the number of arguments
|
||||||
|
uint32_t highest_loglevel = HighestLogLevel();
|
||||||
|
if (top >= 2 && be_isint(vm, 2)) {
|
||||||
|
int32_t log_level = be_toint(vm, 2);
|
||||||
|
be_pushbool(vm, log_level <= highest_loglevel);
|
||||||
|
} else {
|
||||||
|
be_pushint(vm, HighestLogLevel());
|
||||||
|
}
|
||||||
|
be_return(vm);
|
||||||
|
}
|
||||||
|
|
||||||
// Berry: `log(msg:string [,log_level:int]) ->nil`
|
// Berry: `log(msg:string [,log_level:int]) ->nil`
|
||||||
// Logs the string at LOG_LEVEL_INFO (loglevel=2)
|
// Logs the string at LOG_LEVEL_INFO (loglevel=2)
|
||||||
// We allow this function to be called as a method or a direct function
|
// We allow this function to be called as a method or a direct function
|
||||||
|
Loading…
x
Reference in New Issue
Block a user