[libbluray-devel] Allow writing log to file even if application log handler is used
hpi1
git at videolan.org
Thu Jun 15 00:09:29 CEST 2017
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Jun 9 17:43:03 2017 +0300| [b145a01dd20009337f5565cec3add4df213f0b12] | committer: hpi1
Allow writing log to file even if application log handler is used
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=b145a01dd20009337f5565cec3add4df213f0b12
---
src/util/logging.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/util/logging.c b/src/util/logging.c
index 94ef131e..64808720 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -51,7 +51,7 @@ uint32_t bd_get_debug_mask(void)
void bd_debug(const char *file, int line, uint32_t mask, const char *format, ...)
{
- static int debug_init = 0;
+ static int debug_init = 0, debug_file = 0;
static FILE *logfile = NULL;
// Only call getenv() once.
@@ -73,6 +73,7 @@ void bd_debug(const char *file, int line, uint32_t mask, const char *format, ...
if (fp) {
logfile = fp;
setvbuf(logfile, NULL, _IONBF, 0);
+ debug_file = 1;
} else {
fprintf(logfile, "%s:%d: Error opening log file %s\n", __FILE__, __LINE__, env);
}
@@ -102,8 +103,9 @@ void bd_debug(const char *file, int line, uint32_t mask, const char *format, ...
if (lf) {
buffer[sizeof(buffer)-1] = 0;
lf(buffer);
+ }
- } else {
+ if (!lf || debug_file) {
len += len2;
if ((size_t)len >= sizeof(buffer)) {
len = sizeof(buffer);
More information about the libbluray-devel
mailing list