Skip to content

Commit 84c7c3c

Browse files
committed
Merge branch 'trkn-log-to-ase'
* Branch commit log: ase/trkn.cc: redirect juce::Logger to Ase trkn/tracktion_engine/tracktion_engine.h: redirect TRACKTION_LOG to Ase ase/trkn.cc: implement trkn_tracktion_log*() functions Signed-off-by: Tim Janik <timj@gnu.org>
2 parents ddf319f + 735df08 commit 84c7c3c

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

ase/trkn.cc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@ namespace te = tracktion::engine;
1212

1313
namespace Ase {
1414

15+
void // see tracktion_engine.h
16+
trkn_tracktion_log_msg (const juce::String &msg)
17+
{
18+
diag ("TRACKTION: %s", msg.toStdString());
19+
}
20+
21+
void // see tracktion_engine.h
22+
trkn_tracktion_log_error (const juce::String &errmsg)
23+
{
24+
// TRACKTION_LOG_ERROR is mostly used for IO or exec errors
25+
warning ("TRACKTION: error: %s", errmsg.toStdString());
26+
}
27+
1528
struct EngineBehaviour : te::EngineBehaviour {
1629
bool nodevs = false;
1730
bool autoInitialiseDeviceManager () override { return !nodevs; }
@@ -68,6 +81,14 @@ trkn_shutdown ()
6881
trkn_app->shutdownApp();
6982
}
7083

84+
struct AseLogger : public juce::Logger {
85+
void
86+
logMessage (const juce::String &msg) override
87+
{
88+
diag ("JUCE: %s", msg.toStdString());
89+
}
90+
};
91+
7192
/** Setup @ref tracktion and @ref tracktion::engine.
7293
* Initializes juce::JUCEApplication, creates tracktion::engine::Engine, tracktion::engine::DeviceManager,
7394
* scans for Audio and MIDI devices to preapre for playback. Interesting tracktion classes:
@@ -78,6 +99,8 @@ bool
7899
trkn_init (int argc, char *argv[], bool nodevs)
79100
{
80101
assert_return (!trkn_app && main_loop, false);
102+
static AseLogger *logger = new AseLogger();
103+
juce::Logger::setCurrentLogger (logger);
81104
// juce requires a JUCEApplicationBase instance
82105
trkn_app = new TrknApp();
83106
if (!trkn_app->initialiseApp()) {

trkn/tracktion_engine/tracktion_engine.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,14 @@
251251
#endif
252252

253253
#if TRACKTION_LOG_ENABLED
254-
#define TRACKTION_LOG(a) juce::Logger::writeToLog(a)
255-
#define TRACKTION_LOG_ERROR(a) juce::Logger::writeToLog (juce::String ("*** ERROR: ") + a);
254+
namespace Ase {
255+
void trkn_tracktion_log_msg (const juce::String&);
256+
void trkn_tracktion_log_error (const juce::String&);
257+
} // Ase
258+
#define TRACKTION_LOG(a) Ase::trkn_tracktion_log_msg (a)
259+
#define TRACKTION_LOG_ERROR(a) Ase::trkn_tracktion_log_error (a)
260+
// #define TRACKTION_LOG(a) juce::Logger::writeToLog(a)
261+
// #define TRACKTION_LOG_ERROR(a) juce::Logger::writeToLog (juce::String ("*** ERROR: ") + a);
256262
#else
257263
#define TRACKTION_LOG(a) {}
258264
#define TRACKTION_LOG_ERROR(a) {}

0 commit comments

Comments
 (0)