-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
LogStreamSd.cpp
40 lines (36 loc) · 1 KB
/
LogStreamSd.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "LogStreamSd.h"
#include "WrapperWebServer.h"
#include "Hackiebox.h"
#include <Logging.h>
size_t LogStreamSd::write(uint8_t character) {
return write(&character, 1);
}
size_t LogStreamSd::write(const uint8_t *buffer, size_t size) {
if (!Box.boxSD.isInitialized())
return 0;
if (!Config.get()->log.sdLog)
return 0;/*
if (!_isOpen) {
Log.enableAdditionalLogger(false);
Log.info("LogStreamSd::!_isOpen");
Log.enableAdditionalLogger(true);
_isOpen = _file.open("/revvox/logging.log", FA_OPEN_APPEND | FA_WRITE);
if (!_isOpen)
return 0;
}*/
_isOpen = _file.open("/revvox/logging.log", FA_OPEN_APPEND | FA_WRITE);
if (!_isOpen)
return 0;
uint32_t result = _file.write((void*)buffer, (uint32_t)size);
_file.close();
return result;
}
size_t LogStreamSd::println() {
size_t result = print("\r\n");
/*
if (_isOpen) {
_file.close();
_isOpen = false;
}*/
return result;
}