Skip to content

Commit 50b1606

Browse files
SNOW-1017608: fix cpp logging to stderr (#969)
Co-authored-by: Maxymilian Kowalski <maxymilian.kowalski@snowflake.com>
1 parent b3798c3 commit 50b1606

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ set(SOURCE_FILES
6666
lib/chunk_downloader.c
6767
lib/mock_http_perform.h
6868
lib/http_perform.c
69-
lib/log_file_util.h
70-
lib/log_file_util.c
7169
)
7270

7371
set (SOURCE_FILES_PUT_GET
@@ -207,11 +205,13 @@ set(SOURCE_FILES_CPP_WRAPPER
207205
cpp/util/Sha256.cpp
208206
cpp/util/Sha256.hpp
209207
cpp/util/SnowflakeCppUtil.cpp
208+
cpp/util/LogFileUtil.cpp
210209
cpp/platform/SecureStorage.cpp
211210
lib/result_set.h
212211
lib/query_context_cache.h
213212
lib/curl_desc_pool.h
214213
lib/authenticator.h
214+
lib/log_file_util.h
215215
include/snowflake/WifAttestation.hpp
216216
cpp/WifAttestation.cpp
217217
cpp/AwsAttestation.cpp
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
#include "log_file_util.h"
2-
#include <snowflake/logger.h>
2+
#include "../logger/SFLogger.hpp"
33
#ifndef _WIN32
44
#include <errno.h>
55
#include <sys/stat.h>
66
#endif
77

8+
using namespace Snowflake::Client;
9+
extern "C" {
10+
811
void log_warn_when_accessible_by_others(const char *filePath, const char *context, sf_bool log_read_access)
912
{
1013
#ifndef _WIN32
1114
struct stat ret;
1215
if (stat(filePath, &ret) == 0)
1316
{
14-
log_debug("%s File %s access rights %o", context, filePath, ret.st_mode);
17+
CXX_LOG_DEBUG("%s File %s access rights %o", context, filePath, ret.st_mode);
1518
if (log_read_access &&
1619
(ret.st_mode & S_IRGRP || ret.st_mode & S_IROTH))
1720
{
18-
log_warn("%s File %s is accessible by others with permissions %o",
21+
CXX_LOG_WARN("%s File %s is accessible by others with permissions %o",
1922
context, filePath, ret.st_mode);
2023
}
2124
}
2225
else
2326
{
24-
log_warn("%s, Unable to access the file to check the permission: %s. Error %d",
27+
CXX_LOG_WARN("%s, Unable to access the file to check the permission: %s. Error %d",
2528
context, filePath, errno);
2629
}
2730
#endif
2831
}
2932

3033
void log_file_usage(const char* filePath, const char* context, sf_bool log_read_access)
3134
{
32-
log_info("%s Accessing file: %s", context, filePath);
35+
CXX_LOG_INFO("%s Accessing file: %s", context, filePath);
3336
log_warn_when_accessible_by_others(filePath, context, log_read_access);
3437
}
38+
39+
} // extern "C"

0 commit comments

Comments
 (0)