mirror of https://github.com/pvnis/srsRAN_4G.git
- Add common utils to print to stdout and stderr as a first step to remove the log::console method.
parent
58ce9d3959
commit
302f9793ca
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||||||
|
*
|
||||||
|
* This file is part of srsLTE.
|
||||||
|
*
|
||||||
|
* srsLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* srsLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Affero General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRSLTE_STANDARD_STREAMS_H
|
||||||
|
#define SRSLTE_STANDARD_STREAMS_H
|
||||||
|
|
||||||
|
namespace srslte {
|
||||||
|
|
||||||
|
/// Writes a message to a new line on the standard output stream.
|
||||||
|
void out_stream(const char* str, ...);
|
||||||
|
|
||||||
|
/// Writes a message to a new line on the standard error stream.
|
||||||
|
void err_stream(const char* str, ...);
|
||||||
|
|
||||||
|
} // namespace srslte
|
||||||
|
|
||||||
|
#endif // SRSLTE_STANDARD_STREAMS_H
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||||||
|
*
|
||||||
|
* This file is part of srsLTE.
|
||||||
|
*
|
||||||
|
* srsLTE is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* srsLTE is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* A copy of the GNU Affero General Public License can be found in
|
||||||
|
* the LICENSE file in the top-level directory of this distribution
|
||||||
|
* and at http://www.gnu.org/licenses/.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "srslte/common/standard_streams.h"
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
using namespace srslte;
|
||||||
|
|
||||||
|
void srslte::out_stream(const char* str, ...)
|
||||||
|
{
|
||||||
|
std::va_list args;
|
||||||
|
va_start(args, str);
|
||||||
|
char buffer[1024];
|
||||||
|
std::vsnprintf(buffer, sizeof(buffer) - 1, str, args);
|
||||||
|
std::fprintf(stdout, "%s\n", buffer);
|
||||||
|
std::fflush(stdout);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void srslte::err_stream(const char* str, ...)
|
||||||
|
{
|
||||||
|
std::va_list args;
|
||||||
|
va_start(args, str);
|
||||||
|
char buffer[1024];
|
||||||
|
std::vsnprintf(buffer, sizeof(buffer) - 1, str, args);
|
||||||
|
std::fprintf(stderr, "%s\n", buffer);
|
||||||
|
std::fflush(stderr);
|
||||||
|
va_end(args);
|
||||||
|
}
|
Loading…
Reference in New Issue