Merge pull request #1766 from stweil/tprintf

Replace tprintf_internal by tprintf and clean tprintf code
This commit is contained in:
zdenop 2018-07-07 21:55:01 +02:00 committed by GitHub
commit 249ca52672
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 29 deletions

View File

@ -21,6 +21,7 @@
#include "thresholder.h" #include "thresholder.h"
#include <cstdint> // for uint32_t
#include <cstring> #include <cstring>
#include "otsuthr.h" #include "otsuthr.h"

View File

@ -2,7 +2,6 @@
* File: rect.cpp (Formerly box.c) * File: rect.cpp (Formerly box.c)
* Description: Bounding box class definition. * Description: Bounding box class definition.
* Author: Phil Cheatle * Author: Phil Cheatle
* Created: Wed Oct 16 15:18:45 BST 1991
* *
* (C) Copyright 1991, Hewlett-Packard Ltd. * (C) Copyright 1991, Hewlett-Packard Ltd.
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
@ -18,6 +17,7 @@
**********************************************************************/ **********************************************************************/
#include "rect.h" #include "rect.h"
#include "strngs.h" // for STRING
// Include automatically generated configuration file if running autoconf. // Include automatically generated configuration file if running autoconf.
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H

View File

@ -22,8 +22,8 @@
#include "config_auto.h" #include "config_auto.h"
#endif #endif
#include <stdio.h> #include <cstdio>
#include <stdarg.h> #include <cstdarg>
#include "ccutil.h" #include "ccutil.h"
#include "params.h" #include "params.h"
#include "strngs.h" #include "strngs.h"
@ -31,14 +31,11 @@
#define MAX_MSG_LEN 65536 #define MAX_MSG_LEN 65536
#define EXTERN static STRING_VAR(debug_file, "", "File to send tprintf output to");
// Since tprintf is protected by a mutex, these parameters can remain global.
DLLSYM STRING_VAR(debug_file, "", "File to send tprintf output to");
DLLSYM void // Trace printf
tprintf_internal( // Trace printf DLLSYM void tprintf(const char *format, ...)
const char *format, ... // Message {
) {
tesseract::tprintfMutex.Lock(); tesseract::tprintfMutex.Lock();
va_list args; // variable args va_list args; // variable args
static FILE *debugfp = nullptr; // debug file static FILE *debugfp = nullptr; // debug file

View File

@ -20,17 +20,10 @@
#ifndef TESSERACT_CCUTIL_TPRINTF_H #ifndef TESSERACT_CCUTIL_TPRINTF_H
#define TESSERACT_CCUTIL_TPRINTF_H #define TESSERACT_CCUTIL_TPRINTF_H
#include "params.h" #include "platform.h" // for TESS_API
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");
// Main logging function. // Main logging function.
#define tprintf(...) tprintf_internal(__VA_ARGS__) extern TESS_API void tprintf( // Trace printf
extern TESS_API void tprintf_internal( // Trace printf
const char *format, ...); // Message const char *format, ...); // Message
#endif // define TESSERACT_CCUTIL_TPRINTF_H #endif // define TESSERACT_CCUTIL_TPRINTF_H

View File

@ -32,7 +32,7 @@ DECLARE_INT_PARAM_FLAG(tlog_level);
// config file like other params. // config file like other params.
#define tlog(level, ...) { \ #define tlog(level, ...) { \
if (FLAGS_tlog_level >= level) { \ if (FLAGS_tlog_level >= level) { \
tprintf_internal(__VA_ARGS__); \ tprintf(__VA_ARGS__); \
} \ } \
} }