Skip to content

Commit 70fcfb0

Browse files
committed
fix build errors on macos
1 parent 88f1767 commit 70fcfb0

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

.github/workflows/prebuild.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
name: Prebuild Electron ${{ matrix.electron }} on ${{ matrix.os }}
9090
strategy:
9191
matrix:
92-
os: [ubuntu-20.04, windows-2022, macos-latest]
92+
os: [ubuntu-latest, windows-2022, macos-latest]
9393
electron: [32, 33, 34, 35, 36]
9494
runs-on: ${{ matrix.os }}
9595

cpp/include/utils/Logger.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,17 @@ class Logger {
215215
} \
216216
} while (0)
217217

218+
#ifdef __APPLE__
219+
// macOS doesn't support std::ctype<char16_t>, so convert to regular string
220+
#define SQL_LOG_INFO_U16STREAM(expr) \
221+
do { \
222+
if (mssql::Logger::GetInstance().IsEnabled(mssql::LogLevel::Info)) { \
223+
std::ostringstream oss; \
224+
oss << expr; \
225+
mssql::Logger::GetInstance().Info(oss.str()); \
226+
} \
227+
} while (0)
228+
#else
218229
#define SQL_LOG_INFO_U16STREAM(expr) \
219230
do { \
220231
if (mssql::Logger::GetInstance().IsEnabled(mssql::LogLevel::Info)) { \
@@ -223,7 +234,18 @@ class Logger {
223234
mssql::Logger::GetInstance().Info(u16oss.str()); \
224235
} \
225236
} while (0)
237+
#endif
226238

239+
#ifdef __APPLE__
240+
#define SQL_LOG_DEBUG_U16STREAM(expr) \
241+
do { \
242+
if (mssql::Logger::GetInstance().IsEnabled(mssql::LogLevel::Debug)) { \
243+
std::ostringstream oss; \
244+
oss << expr; \
245+
mssql::Logger::GetInstance().Debug(oss.str()); \
246+
} \
247+
} while (0)
248+
#else
227249
#define SQL_LOG_DEBUG_U16STREAM(expr) \
228250
do { \
229251
if (mssql::Logger::GetInstance().IsEnabled(mssql::LogLevel::Debug)) { \
@@ -232,7 +254,18 @@ class Logger {
232254
mssql::Logger::GetInstance().Debug(u16oss.str()); \
233255
} \
234256
} while (0)
257+
#endif
235258

259+
#ifdef __APPLE__
260+
#define SQL_LOG_TRACE_U16STREAM(expr) \
261+
do { \
262+
if (mssql::Logger::GetInstance().IsEnabled(mssql::LogLevel::Trace)) { \
263+
std::ostringstream oss; \
264+
oss << expr; \
265+
mssql::Logger::GetInstance().Trace(oss.str()); \
266+
} \
267+
} while (0)
268+
#else
236269
#define SQL_LOG_TRACE_U16STREAM(expr) \
237270
do { \
238271
if (mssql::Logger::GetInstance().IsEnabled(mssql::LogLevel::Trace)) { \
@@ -241,6 +274,7 @@ class Logger {
241274
mssql::Logger::GetInstance().Trace(u16oss.str()); \
242275
} \
243276
} while (0)
277+
#endif
244278

245279
// Function entry/exit logging helpers
246280
#define SQL_LOG_FUNC_ENTRY() \

cpp/src/js/workers/open_worker.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <utils/Logger.h>
44
#include <common/odbc_common.h>
5+
#include <common/string_utils.h>
56
#include <js/Connection.h>
67
#include <js/js_object_mapper.h>
78
#include <odbc/odbc_connection.h>
@@ -17,12 +18,20 @@ OpenWorker::OpenWorker(Napi::Function& callback,
1718
parent_(parent),
1819
connectionString_(connectionString),
1920
connectionId_(-1) {
21+
#ifdef __APPLE__
22+
SQL_LOG_DEBUG_U16STREAM("OpenWorker constructor for connection: " << StringUtils::U16StringToUtf8(connectionString_));
23+
#else
2024
SQL_LOG_DEBUG_U16STREAM("OpenWorker constructor for connection: " << connectionString_);
25+
#endif
2126
}
2227

2328
void OpenWorker::Execute() {
2429
try {
30+
#ifdef __APPLE__
31+
SQL_LOG_DEBUG_U16STREAM("Executing OpenWorker for connection: " << StringUtils::U16StringToUtf8(connectionString_));
32+
#else
2533
SQL_LOG_DEBUG_U16STREAM("Executing OpenWorker for connection: " << connectionString_);
34+
#endif
2635

2736
if (!connection_->Open(connectionString_, 0)) {
2837
SetError("Failed to open connection");

0 commit comments

Comments
 (0)