Skip to content

Commit

Permalink
Replace tprintf_internal by tprintf and clean tprintf code
Browse files Browse the repository at this point in the history
Commit 4d514d5 introduced tprintf_internal
with an additional argument "level" which was removed again in commit
7dc5296.

So we can now restore the original state without tprintf_internal.

Remove also the declaration of debug_window_on (it does not exist since
commit 030aae9) and make the
configuration parameter debug_file local as it is only used by tprintf.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 7, 2018
1 parent 24bf8c3 commit 0d49759
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
23 changes: 10 additions & 13 deletions src/ccutil/tprintf.cpp
Expand Up @@ -22,23 +22,20 @@
#include "config_auto.h"
#endif

#include <stdio.h>
#include <stdarg.h>
#include "ccutil.h"
#include "params.h"
#include "strngs.h"
#include "tprintf.h"
#include <cstdio>
#include <cstdarg>
#include "ccutil.h"
#include "params.h"
#include "strngs.h"
#include "tprintf.h"

#define MAX_MSG_LEN 65536

#define EXTERN
// Since tprintf is protected by a mutex, these parameters can remain global.
DLLSYM STRING_VAR(debug_file, "", "File to send tprintf output to");
static STRING_VAR(debug_file, "", "File to send tprintf output to");

DLLSYM void
tprintf_internal( // Trace printf
const char *format, ... // Message
) {
// Trace printf
DLLSYM void tprintf(const char *format, ...)
{
tesseract::tprintfMutex.Lock();
va_list args; // variable args
static FILE *debugfp = nullptr; // debug file
Expand Down
17 changes: 5 additions & 12 deletions src/ccutil/tprintf.h
Expand Up @@ -17,20 +17,13 @@
*
**********************************************************************/

#ifndef TESSERACT_CCUTIL_TPRINTF_H
#define TESSERACT_CCUTIL_TPRINTF_H
#ifndef TESSERACT_CCUTIL_TPRINTF_H
#define TESSERACT_CCUTIL_TPRINTF_H

#include "params.h"

extern DLLSYM STRING_VAR_H(debug_file, "",
"File to send tprintf output to");
extern DLLSYM BOOL_VAR_H(debug_window_on, TRUE,
"Send tprintf to window unless file set");
#include "platform.h" // for TESS_API

// Main logging function.
#define tprintf(...) tprintf_internal(__VA_ARGS__)

extern TESS_API void tprintf_internal( // Trace printf
const char *format, ...); // Message
extern TESS_API void tprintf( // Trace printf
const char *format, ...); // Message

#endif // define TESSERACT_CCUTIL_TPRINTF_H
2 changes: 1 addition & 1 deletion src/training/tlog.h
Expand Up @@ -32,7 +32,7 @@ DECLARE_INT_PARAM_FLAG(tlog_level);
// config file like other params.
#define tlog(level, ...) { \
if (FLAGS_tlog_level >= level) { \
tprintf_internal(__VA_ARGS__); \
tprintf(__VA_ARGS__); \
} \
}

Expand Down

0 comments on commit 0d49759

Please sign in to comment.