Skip to content

Commit f27ec2a

Browse files
committed
Logging Cleanup
1 parent 7b6820b commit f27ec2a

File tree

6 files changed

+46
-47
lines changed

6 files changed

+46
-47
lines changed

src/AudioA2DP.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int32_t a2dp_stream_source_sound_data(Channels* data, int32_t len) {
6060
size_t result_len_bytes = a2dp_buffer.readArray((uint8_t*)data, len*sizeof(Channels));
6161
// result is in number of frames
6262
result_len = result_len_bytes / sizeof(Channels);
63-
ESP_LOGI( "a2dp_stream_source_sound_data %d -> %d", len ,result_len);
63+
LOGI("a2dp_stream_source_sound_data %d -> %d", len ,result_len);
6464
// allow some other task
6565
yield();
6666
return result_len;
@@ -70,7 +70,7 @@ int32_t a2dp_stream_source_sound_data(Channels* data, int32_t len) {
7070
void a2dp_stream_sink_sound_data(const uint8_t* data, uint32_t len) {
7171
if (is_a2dp_setup){
7272
uint32_t result_len = a2dp_buffer.writeArray(data, len);
73-
ESP_LOGI( "a2dp_stream_sink_sound_data %d -> %d", len, result_len);
73+
LOGI("a2dp_stream_sink_sound_data %d -> %d", len, result_len);
7474
// allow some other task
7575
yield();
7676
}
@@ -170,9 +170,9 @@ class A2DPStream : public Stream {
170170
size_t result = 0;
171171
if (is_a2dp_setup){
172172
result = a2dp_buffer.writeArray(data,len);
173-
ESP_LOGI( "write %d->%d", len,result);
173+
LOGI("write %d->%d", len,result);
174174
} else {
175-
ESP_LOGW( "write failed because !is_a2dp_setup");
175+
LOGW( "write failed because !is_a2dp_setup");
176176
}
177177
return result;
178178
}
@@ -193,21 +193,21 @@ class A2DPStream : public Stream {
193193
size_t result = 0;
194194
if (is_a2dp_setup){
195195
result = a2dp_buffer.readArray(data, len);
196-
ESP_LOGI( "read %d->%d", len,result);
196+
LOGI("read %d->%d", len,result);
197197
} else {
198-
ESP_LOGW( "readBytes failed because !is_a2dp_setup");
198+
LOGW( "readBytes failed because !is_a2dp_setup");
199199
}
200200
return result;
201201
}
202202

203203
// not supported
204204
virtual int read() {
205-
ESP_LOGE( "read() not supported");
205+
LOGE( "read() not supported");
206206
return -1;
207207
}
208208
// not supported
209209
virtual int peek() {
210-
ESP_LOGE( "peek() not supported");
210+
LOGE( "peek() not supported");
211211
return -1;
212212
}
213213

src/AudioConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
#ifdef USE_LOGGING
8181
#define LOGD(...) AudioLogger::instance().printLog(__FILENAME__,__LINE__, AudioLogger::Debug, __VA_ARGS__)
8282
#define LOGI(...) AudioLogger::instance().printLog(__FILENAME__,__LINE__, AudioLogger::Info, __VA_ARGS__)
83-
#define LOGW(...) AudioLogger::instance().printLog(__FILENAME__,__LINE__, AudioLogger::Warn, __VA_ARGS__)
83+
#define LOGW(...) AudioLogger::instance().printLog(__FILENAME__,__LINE__, AudioLogger::Warning, __VA_ARGS__)
8484
#define LOGE(...) AudioLogger::instance().printLog(__FILENAME__,__LINE__, AudioLogger::Error, __VA_ARGS__)
8585
#else
8686
#define LOGD(...)

src/AudioNet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class UDPStream : public WiFiUDP {
4141
public:
4242

4343
virtual uint8_t begin(IPAddress remote_host, uint16_t remote_port, uint16_t local_port=0, bool multicast = false ) {
44-
ESP_LOGI(AUDIO_TAG, "begin");
44+
LOGI( "begin");
4545
this->remote_host = remote_host;
4646
this->remote_port = remote_port;
4747
this->local_port = local_port != 0 ? local_port : remote_port;
@@ -61,7 +61,7 @@ class UDPStream : public WiFiUDP {
6161
}
6262

6363
virtual size_t write(const uint8_t *buffer, size_t size) {
64-
ESP_LOGD(AUDIO_TAG, "write %u bytes", size);
64+
LOGD( "write %u bytes", size);
6565
beginPacket(remote_host, remote_port);
6666
size_t result = WiFiUDP::write(buffer, size);
6767
endPacket();

src/AudioTools/AnalogAudio.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class AnalogConfig {
104104
break;
105105

106106
default:
107-
ESP_LOGE(ADC_TAG, "%s - pin GPIO%d is not supported", __func__,gpio);
107+
LOGE( "%s - pin GPIO%d is not supported", __func__,gpio);
108108
}
109109
}
110110

@@ -136,14 +136,14 @@ class AnalogAudio {
136136

137137
/// Provides the default configuration
138138
AnalogConfig defaultConfig(RxTxMode mode) {
139-
ESP_LOGD(ADC_TAG, "%s", __func__);
139+
LOGD( "%s", __func__);
140140
AnalogConfig config(mode);
141141
return config;
142142
}
143143

144144
/// starts the DAC
145145
void begin(AnalogConfig cfg) {
146-
ESP_LOGI(ADC_TAG, "%s", __func__);
146+
LOGI("%s", __func__);
147147
disableCore0WDT();
148148

149149
adc_config = cfg;
@@ -163,37 +163,37 @@ class AnalogAudio {
163163

164164
// setup config
165165
if (i2s_driver_install(i2s_num, &i2s_config, 0, NULL)!=ESP_OK){
166-
ESP_LOGE(ADC_TAG, "%s - %s", __func__, "i2s_driver_install");
166+
LOGE( "%s - %s", __func__, "i2s_driver_install");
167167
}
168168

169169
// clear i2s buffer
170170
if (i2s_zero_dma_buffer(i2s_num)!=ESP_OK) {
171-
ESP_LOGE(ADC_TAG, "%s - %s", __func__, "i2s_zero_dma_buffer");
171+
LOGE( "%s - %s", __func__, "i2s_zero_dma_buffer");
172172
}
173173

174174
switch (cfg.mode) {
175175
case RX_MODE:
176176
//init ADC pad
177177
if (i2s_set_adc_mode(cfg.unit, cfg.channel)!=ESP_OK) {
178-
ESP_LOGE(ADC_TAG, "%s - %s", __func__, "i2s_driver_install");
178+
LOGE( "%s - %s", __func__, "i2s_driver_install");
179179
}
180180

181181
// enable the ADC
182182
if (i2s_adc_enable(i2s_num)!=ESP_OK) {
183-
ESP_LOGE(ADC_TAG, "%s - %s", __func__, "i2s_adc_enable");
183+
LOGE( "%s - %s", __func__, "i2s_adc_enable");
184184
}
185185
break;
186186
case TX_MODE:
187187
i2s_set_pin(i2s_num, NULL);
188188
break;
189189
}
190-
ESP_LOGI(ADC_TAG, "%s - %s", __func__,"end");
190+
LOGI(ADC_TAG, "%s - %s", __func__,"end");
191191

192192
}
193193

194194
/// stops the I2C and unistalls the driver
195195
void end(){
196-
ESP_LOGD(ADC_TAG, "%s", __func__);
196+
LOGD( "%s", __func__);
197197
enableCore0WDT();
198198
i2s_driver_uninstall(i2s_num);
199199
}
@@ -202,7 +202,7 @@ class AnalogAudio {
202202
size_t read(int16_t (*src)[2], size_t sizeFrames){
203203
size_t len = readBytes(src, sizeFrames * sizeof(int16_t)*2); // 2 bytes * 2 channels
204204
size_t result = len / (sizeof(int16_t) * 2);
205-
ESP_LOGD(ADC_TAG, "%s - len: %d -> %d", __func__,sizeFrames, result);
205+
LOGD( "%s - len: %d -> %d", __func__,sizeFrames, result);
206206
return result;
207207
}
208208

@@ -218,17 +218,17 @@ class AnalogAudio {
218218
size_t writeBytes(const void *src, size_t size_bytes){
219219
size_t result = 0;
220220
if (i2s_write(i2s_num, src, size_bytes, &result, portMAX_DELAY)!=ESP_OK){
221-
ESP_LOGE("%s", __func__);
221+
LOGE("%s", __func__);
222222
}
223223
return result;
224224
}
225225

226226
size_t readBytes(void *dest, size_t size_bytes){
227227
size_t result = 0;
228228
if (i2s_read(i2s_num, dest, size_bytes, &result, portMAX_DELAY)!=ESP_OK){
229-
ESP_LOGE("%s", __func__);
229+
LOGE("%s", __func__);
230230
}
231-
ESP_LOGD(ADC_TAG, "%s - len: %d -> %d", __func__, size_bytes, result);
231+
LOGD( "%s - len: %d -> %d", __func__, size_bytes, result);
232232
//vTaskDelay(1);
233233
return result;
234234
}

src/AudioTools/AudioCopy.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class StreamCopyT {
2323
this->buffer_size = buffer_size;
2424
buffer = new uint8_t[buffer_size];
2525
if (buffer==nullptr){
26-
ESP_LOGE("Could not allocate enough memory for StreamCopy: %d bytes", buffer_size);
26+
LOGE("Could not allocate enough memory for StreamCopy: %d bytes", buffer_size);
2727
}
2828
}
2929

@@ -37,7 +37,7 @@ class StreamCopyT {
3737
size_t delayCount = 0;
3838
size_t len = available();
3939
size_t bytes_to_read;
40-
ESP_LOGI("StreamCopyT::copy - begin");
40+
LOGI("StreamCopyT::copy - begin");
4141

4242
if (len>0){
4343
bytes_to_read = min(len, static_cast<size_t>(buffer_size));
@@ -46,7 +46,7 @@ class StreamCopyT {
4646
size_t bytes_read = from->readBytes(buffer, bytes_to_read);
4747
result = write(bytes_read,delayCount);
4848
}
49-
ESP_LOGI("StreamCopy::copy %u -> %u bytes - in %d hops\n", bytes_to_read, result, delayCount);
49+
LOGI("StreamCopy::copy %u -> %u bytes - in %d hops\n", bytes_to_read, result, delayCount);
5050
return result;
5151
}
5252

@@ -58,7 +58,7 @@ class StreamCopyT {
5858
size_t bytes_read;
5959
size_t len = available();
6060
size_t bytes_to_read;
61-
ESP_LOGI("StreamCopyT::copy2 - begin");
61+
LOGI("StreamCopyT::copy2 - begin");
6262

6363
if (len>0){
6464
bytes_to_read = min(len, static_cast<size_t>(buffer_size / 2));
@@ -77,7 +77,7 @@ class StreamCopyT {
7777
}
7878
result = write(samples * sizeof(T)*2, delayCount);
7979
}
80-
ESP_LOGI("StreamCopy::copy %u -> %u bytes - in %d hops", bytes_to_read, result, delayCount);
80+
LOGI("StreamCopy::copy %u -> %u bytes - in %d hops", bytes_to_read, result, delayCount);
8181
return result;
8282
}
8383

@@ -130,7 +130,7 @@ class StreamCopy : public StreamCopyT<uint8_t> {
130130
write(result, delayCount);
131131
}
132132

133-
ESP_LOGI("StreamCopy::copy %d bytes - in %d hops\n", result, delayCount);
133+
LOGI("StreamCopy::copy %d bytes - in %d hops\n", result, delayCount);
134134
return result;
135135
}
136136

src/AudioTools/I2S_ESP32.h

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ class I2SBase {
1818

1919
/// Provides the default configuration
2020
I2SConfig defaultConfig(RxTxMode mode) {
21-
ESP_LOGD("%s", __func__);
2221
I2SConfig c(mode);
2322
return c;
2423
}
2524

2625
/// starts the DAC
2726
void begin(I2SConfig cfg) {
28-
ESP_LOGD("%s", __func__);
27+
LOGD("%s", __func__);
2928
this->cfg = cfg;
3029
this->i2s_num = (i2s_port_t) cfg.port_no;
3130
setChannels(cfg.channels);
@@ -47,13 +46,13 @@ class I2SBase {
4746
// We make sure that we can reconfigure
4847
if (is_started) {
4948
end();
50-
ESP_LOGD("%s", "I2S restarting");
49+
LOGD("%s", "I2S restarting");
5150
}
5251

5352

5453
// setup config
5554
if (i2s_driver_install(i2s_num, &i2s_config, 0, NULL)!=ESP_OK){
56-
ESP_LOGE("%s - %s", __func__, "i2s_driver_install");
55+
LOGE("%s - %s", __func__, "i2s_driver_install");
5756
}
5857

5958
// setup pin config
@@ -67,10 +66,10 @@ class I2SBase {
6766
logConfigPins(pin_config);
6867

6968
if (i2s_set_pin(i2s_num, &pin_config)!= ESP_OK){
70-
ESP_LOGE("%s - %s", __func__, "i2s_set_pin");
69+
LOGE("%s - %s", __func__, "i2s_set_pin");
7170
}
7271
} else {
73-
ESP_LOGD("Using built in DAC");
72+
LOGD("Using built in DAC");
7473
//for internal DAC, this will enable both of the internal channels
7574
i2s_set_pin(i2s_num, NULL);
7675
}
@@ -79,12 +78,12 @@ class I2SBase {
7978
i2s_zero_dma_buffer(i2s_num);
8079

8180
is_started = true;
82-
ESP_LOGD("%s - %s", __func__, "started");
81+
LOGD("%s - %s", __func__, "started");
8382
}
8483

8584
/// stops the I2C and unistalls the driver
8685
void end(){
87-
ESP_LOGD("%s", __func__);
86+
LOGD("%s", __func__);
8887
i2s_driver_uninstall(i2s_num);
8988
is_started = false;
9089
}
@@ -115,30 +114,30 @@ class I2SBase {
115114
size_t writeBytes(const void *src, size_t size_bytes){
116115
size_t result = 0;
117116
if (i2s_write(i2s_num, src, size_bytes, &result, portMAX_DELAY)!=ESP_OK){
118-
ESP_LOGE("%s", __func__);
117+
LOGE("%s", __func__);
119118
}
120119
return result;
121120
}
122121

123122
size_t readBytes(void *dest, size_t size_bytes){
124123
size_t result = 0;
125124
if (i2s_read(i2s_num, dest, size_bytes, &result, portMAX_DELAY)!=ESP_OK){
126-
ESP_LOGE("%s", __func__);
125+
LOGE("%s", __func__);
127126
}
128127
return result;
129128
}
130129

131130
void logConfig() {
132-
ESP_LOGI("mode: %s", cfg.rx_tx_mode == TX_MODE ? "TX":"RX");
133-
ESP_LOGI("sample rate: %d", cfg.sample_rate);
134-
ESP_LOGI("bits per sample: %d", cfg.bits_per_sample);
135-
ESP_LOGI("number of channels: %d", cfg.channels);
131+
LOGI("mode: %s", cfg.rx_tx_mode == TX_MODE ? "TX":"RX");
132+
LOGI("sample rate: %d", cfg.sample_rate);
133+
LOGI("bits per sample: %d", cfg.bits_per_sample);
134+
LOGI("number of channels: %d", cfg.channels);
136135
}
137136

138137
void logConfigPins(i2s_pin_config_t pin_config){
139-
ESP_LOGI("pin bck_io_num: %d", cfg.pin_bck);
140-
ESP_LOGI("pin ws_io_num: %d", cfg.pin_ws);
141-
ESP_LOGI("pin data_num: %d", cfg.pin_data);
138+
LOGI("pin bck_io_num: %d", cfg.pin_bck);
139+
LOGI("pin ws_io_num: %d", cfg.pin_ws);
140+
LOGI("pin data_num: %d", cfg.pin_data);
142141
}
143142

144143
};

0 commit comments

Comments
 (0)