1
1
// Copyright The OpenTelemetry Authors
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
+ #include < nlohmann/json.hpp>
5
+
4
6
#include < limits.h>
5
7
#include < atomic>
6
8
#include < chrono>
12
14
#include < fstream>
13
15
#include < functional>
14
16
#include < mutex>
15
- #include < nlohmann/json.hpp>
16
17
#include < ratio>
17
18
#include < string>
18
19
#include < thread>
@@ -1028,21 +1029,21 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
1028
1029
1029
1030
MaybeRotateLog (data.size ());
1030
1031
1031
- std::shared_ptr<FILE> out = OpenLogFile (true );
1032
+ std::shared_ptr<std:: FILE> out = OpenLogFile (true );
1032
1033
if (!out)
1033
1034
{
1034
1035
return ;
1035
1036
}
1036
1037
1037
- fwrite (data.data (), 1 , data.size (), out.get ());
1038
+ std:: fwrite (data.data (), 1 , data.size (), out.get ());
1038
1039
1039
1040
{
1040
1041
std::lock_guard<std::mutex> lock_guard{file_->file_lock };
1041
1042
1042
1043
file_->record_count += record_count;
1043
1044
1044
1045
// Pipe file size always returns 0, we ignore the size limit of it.
1045
- auto written_size = ftell (out.get ());
1046
+ auto written_size = std:: ftell (out.get ());
1046
1047
if (written_size >= 0 )
1047
1048
{
1048
1049
file_->written_size = static_cast <std::size_t >(written_size);
@@ -1054,7 +1055,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
1054
1055
{
1055
1056
file_->left_flush_record_count = options_.flush_count ;
1056
1057
1057
- fflush (out.get ());
1058
+ std:: fflush (out.get ());
1058
1059
1059
1060
file_->flushed_record_count .store (file_->record_count .load (std::memory_order_acquire),
1060
1061
std::memory_order_release);
@@ -1216,7 +1217,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
1216
1217
OpenLogFile (false );
1217
1218
}
1218
1219
1219
- std::shared_ptr<FILE> OpenLogFile (bool destroy_content)
1220
+ std::shared_ptr<std:: FILE> OpenLogFile (bool destroy_content)
1220
1221
{
1221
1222
std::lock_guard<std::mutex> lock_guard{file_->file_lock };
1222
1223
@@ -1238,8 +1239,6 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
1238
1239
}
1239
1240
file_path[file_path_size] = 0 ;
1240
1241
1241
- std::shared_ptr<FILE> of = std::make_shared<FILE>();
1242
-
1243
1242
std::string directory_name = FileSystemUtil::DirName (file_path);
1244
1243
if (!directory_name.empty ())
1245
1244
{
@@ -1294,10 +1293,10 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
1294
1293
<< " failed with pattern: " << options_.file_pattern << hint);
1295
1294
return nullptr ;
1296
1295
}
1297
- of = std::shared_ptr<std::FILE>(new_file, fclose);
1296
+ std::shared_ptr<std::FILE> of = std::shared_ptr<std::FILE>(new_file, fclose);
1298
1297
1299
- fseek (of.get (), 0 , SEEK_END);
1300
- file_->written_size = static_cast <size_t >(ftell (of.get ()));
1298
+ std:: fseek (of.get (), 0 , SEEK_END);
1299
+ file_->written_size = static_cast <size_t >(std:: ftell (of.get ()));
1301
1300
1302
1301
file_->current_file = of;
1303
1302
file_->last_checkpoint = std::chrono::system_clock::to_time_t (std::chrono::system_clock::now ());
@@ -1513,7 +1512,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
1513
1512
1514
1513
if (concurrency_file->current_file )
1515
1514
{
1516
- fflush (concurrency_file->current_file .get ());
1515
+ std:: fflush (concurrency_file->current_file .get ());
1517
1516
}
1518
1517
1519
1518
concurrency_file->flushed_record_count .store (current_record_count,
@@ -1568,7 +1567,7 @@ class OPENTELEMETRY_LOCAL_SYMBOL OtlpFileSystemBackend : public OtlpFileAppender
1568
1567
std::size_t rotate_index;
1569
1568
std::size_t written_size;
1570
1569
std::size_t left_flush_record_count;
1571
- std::shared_ptr<FILE> current_file;
1570
+ std::shared_ptr<std:: FILE> current_file;
1572
1571
std::mutex file_lock;
1573
1572
std::time_t last_checkpoint;
1574
1573
std::string file_path;
0 commit comments