1
+ #include "../logging-utils/logging.h"
1
2
#include "intypes.h"
2
3
#include "packet_types.h"
3
4
#include <errno.h>
@@ -80,7 +81,7 @@ int main(int argc, char **argv) {
80
81
if (infile != NULL ) {
81
82
input = fopen (infile , "r" );
82
83
if (input == NULL ) {
83
- fprintf (stderr , "File '%s' could not be opened for reading.\n" , infile );
84
+ log_print (stderr , LOG_ERROR , "File '%s' could not be opened for reading.\n" , infile );
84
85
exit (EXIT_FAILURE );
85
86
}
86
87
}
@@ -92,7 +93,8 @@ int main(int argc, char **argv) {
92
93
/* Open input message queue. */
93
94
mqd_t in_q = mq_open (INPUT_QUEUE , O_RDONLY , & in_q_attr );
94
95
if (in_q == -1 ) {
95
- fprintf (stderr , "Could not open input message queue %s with error %s\n" , INPUT_QUEUE , strerror (errno ));
96
+ log_print (stderr , LOG_ERROR , "Could not open input message queue %s with error %s\n" , INPUT_QUEUE ,
97
+ strerror (errno ));
96
98
exit (EXIT_FAILURE );
97
99
}
98
100
@@ -104,7 +106,7 @@ int main(int argc, char **argv) {
104
106
};
105
107
mqd_t out_q = mq_open (OUTPUT_QUEUE , O_CREAT | O_WRONLY , S_IWOTH , & q_attributes );
106
108
if (out_q == -1 ) {
107
- fprintf (stderr , "Could not open output queue %s with error %s\n" , OUTPUT_QUEUE , strerror (errno ));
109
+ log_print (stderr , LOG_ERROR , "Could not open output queue %s with error %s\n" , OUTPUT_QUEUE , strerror (errno ));
108
110
exit (EXIT_FAILURE );
109
111
}
110
112
@@ -123,7 +125,8 @@ int main(int argc, char **argv) {
123
125
124
126
/* Read input data. */
125
127
if (mq_receive (in_q , (char * )& recv_msg , sizeof (recv_msg ), & last_priority ) == -1 ) {
126
- fprintf (stderr , "Could not read message from queue %s with error %s\n" , INPUT_QUEUE , strerror (errno ));
128
+ log_print (stderr , LOG_ERROR , "Could not read message from queue %s with error %s\n" , INPUT_QUEUE ,
129
+ strerror (errno ));
127
130
continue ;
128
131
}
129
132
@@ -196,7 +199,7 @@ int main(int argc, char **argv) {
196
199
// Ignore this data for now, currently useful as debug output
197
200
break ;
198
201
default :
199
- fprintf (stderr , "Unknown input data type: %u\n" , recv_msg .type );
202
+ log_print (stderr , LOG_ERROR , "Unknown input data type: %u\n" , recv_msg .type );
200
203
continue ; // Skip to next iteration without storing block
201
204
}
202
205
@@ -209,7 +212,8 @@ int main(int argc, char **argv) {
209
212
210
213
// Send packet with the priority matching the highest priority data received
211
214
if (mq_send (out_q , (char * )packet , packet_header_get_length ((PacketHeader * )packet ), highest_priority ) == -1 ) {
212
- fprintf (stderr , "Failed to output encoded packet #%u with error: %s\n" , pkt_count - 1 , strerror (errno ));
215
+ log_print (stderr , LOG_ERROR , "Failed to output encoded packet #%u with error: %s\n" , pkt_count - 1 ,
216
+ strerror (errno ));
213
217
}
214
218
215
219
if (print_output ) packet_print_hex (stdout , packet );
0 commit comments