Commit 06fc2ac0 authored by Felix Paul Kühne's avatar Felix Paul Kühne Committed by Caro

VLCLibrary: add API to log debug info to a file

(cherry picked from commit fdc3e809)
parent c74574cf
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
* VLCLibrary.h: VLCKit.framework VLCLibrary header * VLCLibrary.h: VLCKit.framework VLCLibrary header
***************************************************************************** *****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont * Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 VLC authors and VideoLAN * Copyright (C) 2007-2019 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org> * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
* Felix Paul Kühne <fkuehne # videolan.org>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by * under the terms of the GNU Lesser General Public License as published by
...@@ -62,10 +63,20 @@ ...@@ -62,10 +63,20 @@
/** /**
* Gets/sets the debug logging level * Gets/sets the debug logging level
* \note Logging level ranges from 0 (just error messages) to 4 (everything) * \note Logging level ranges from 0 (just error messages) to 4 (everything)
* \note values set here will be ignored when logging to a file
* \warning If an invalid level is provided, level defaults to 0 * \warning If an invalid level is provided, level defaults to 0
*/ */
@property (readwrite, nonatomic) int debugLoggingLevel; @property (readwrite, nonatomic) int debugLoggingLevel;
/**
* Activates debug logging to a file stream
* If the file already exists, the log will be appended by the end. If it does not exist, will be created.
* The file will continously updated with new messages from this library instance.
* \note It is the client app's obligation to ensure that the target file path is writable and all subfolders exist
* \warning when enabling this feature, logging to the console will be stopped automatically
*/
- (void)setDebugLoggingToFile:(NSString * _Nonnull)filePath;
/** /**
* Returns the library's version * Returns the library's version
* \return The library version example "0.9.0-git Grishenko" * \return The library version example "0.9.0-git Grishenko"
......
Version 3.2.1:
--------------
- Add API to VLCLibrary to log debug information to a file
Version 3.2.0: Version 3.2.0:
-------------- --------------
- Enabled libmux module - Enabled libmux module
...@@ -23,9 +27,6 @@ VLCTranscoderDelegate: ...@@ -23,9 +27,6 @@ VLCTranscoderDelegate:
VLCTranscoder: VLCTranscoder:
- (BOOL)reencodeAndMuxSRTFile:(NSString *)srtPath toMP4File:(NSString *)mp4Path outputPath:(NSString *)outPath - (BOOL)reencodeAndMuxSRTFile:(NSString *)srtPath toMP4File:(NSString *)mp4Path outputPath:(NSString *)outPath
Version 3.1.5: Version 3.1.5:
-------------- --------------
- Fixed a crash when updateProgressCallback was called - Fixed a crash when updateProgressCallback was called
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
* VLCLibrary.m: VLCKit.framework VLCLibrary implementation * VLCLibrary.m: VLCKit.framework VLCLibrary implementation
***************************************************************************** *****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont * Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 VLC authors and VideoLAN * Copyright (C) 2007-2019 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Pierre d'Herbemont <pdherbemont # videolan.org> * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
* Felix Paul Kühne <fkuehne # videolan.org>
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by * under the terms of the GNU Lesser General Public License as published by
...@@ -47,6 +48,12 @@ static void HandleMessage(void *, ...@@ -47,6 +48,12 @@ static void HandleMessage(void *,
static VLCLibrary * sharedLibrary = nil; static VLCLibrary * sharedLibrary = nil;
@interface VLCLibrary()
{
FILE *_logFileStream;
}
@end
@implementation VLCLibrary @implementation VLCLibrary
+ (VLCLibrary *)sharedLibrary + (VLCLibrary *)sharedLibrary
...@@ -149,6 +156,9 @@ static VLCLibrary * sharedLibrary = nil; ...@@ -149,6 +156,9 @@ static VLCLibrary * sharedLibrary = nil;
libvlc_log_set(_instance, HandleMessage, (__bridge void *)(self)); libvlc_log_set(_instance, HandleMessage, (__bridge void *)(self));
} else { } else {
libvlc_log_unset(_instance); libvlc_log_unset(_instance);
if (_logFileStream)
fclose(_logFileStream);
} }
} }
...@@ -164,6 +174,25 @@ static VLCLibrary * sharedLibrary = nil; ...@@ -164,6 +174,25 @@ static VLCLibrary * sharedLibrary = nil;
} }
} }
- (void)setDebugLoggingToFile:(NSString * _Nonnull)filePath
{
if (!filePath)
return;
if (!_instance)
return;
if (_debugLogging) {
libvlc_log_unset(_instance);
}
_logFileStream = fopen([filePath UTF8String], "a");
if (_logFileStream) {
libvlc_log_set_file(_instance, _logFileStream);
}
}
- (NSString *)version - (NSString *)version
{ {
return @(libvlc_get_version()); return @(libvlc_get_version());
...@@ -193,8 +222,14 @@ static VLCLibrary * sharedLibrary = nil; ...@@ -193,8 +222,14 @@ static VLCLibrary * sharedLibrary = nil;
- (void)dealloc - (void)dealloc
{ {
if (_instance) if (_instance) {
libvlc_log_unset(_instance);
libvlc_release(_instance); libvlc_release(_instance);
}
if (_logFileStream) {
fclose(_logFileStream);
}
} }
@end @end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment