react-native-nitro-logger 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/LICENSE +20 -0
  2. package/NitroLogger.podspec +29 -0
  3. package/README.md +214 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +124 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +11 -0
  8. package/android/src/main/java/com/margelo/nitro/nitrologger/AndroidPlatformIo.kt +100 -0
  9. package/android/src/main/java/com/margelo/nitro/nitrologger/HybridFileSink.kt +292 -0
  10. package/android/src/main/java/com/margelo/nitro/nitrologger/HybridNativeConsoleSink.kt +23 -0
  11. package/android/src/main/java/com/margelo/nitro/nitrologger/LogFileWriter.kt +1328 -0
  12. package/android/src/main/java/com/margelo/nitro/nitrologger/LogRotationPolicy.kt +186 -0
  13. package/android/src/main/java/com/margelo/nitro/nitrologger/LogSecureFile.kt +80 -0
  14. package/android/src/main/java/com/margelo/nitro/nitrologger/LogWriterRegistry.kt +420 -0
  15. package/android/src/main/java/com/margelo/nitro/nitrologger/NativeConsoleWriter.kt +237 -0
  16. package/android/src/main/java/com/margelo/nitro/nitrologger/NitroLoggerPackage.kt +22 -0
  17. package/android/src/main/java/com/margelo/nitro/nitrologger/PlatformIo.kt +165 -0
  18. package/docs/PARITY.md +330 -0
  19. package/docs/PRIVACY.md +341 -0
  20. package/eslint-plugin/README.md +238 -0
  21. package/eslint-plugin/index.js +62 -0
  22. package/eslint-plugin/rules/literal-subsystem.js +102 -0
  23. package/eslint-plugin/rules/no-computed-metadata-key.js +174 -0
  24. package/eslint-plugin/rules/no-derived-correlation.js +171 -0
  25. package/eslint-plugin/rules/no-dynamic-message.js +60 -0
  26. package/eslint-plugin/shared.js +1948 -0
  27. package/ios/Gzip.swift +203 -0
  28. package/ios/HybridFileSink.swift +291 -0
  29. package/ios/HybridNativeConsoleSink.swift +20 -0
  30. package/ios/LogFileWriter.swift +1280 -0
  31. package/ios/LogSecureFile.swift +296 -0
  32. package/ios/LogWriterRegistry.swift +444 -0
  33. package/ios/NativeConsoleWriter.swift +180 -0
  34. package/lib/module/Logger.js +381 -0
  35. package/lib/module/Logger.js.map +1 -0
  36. package/lib/module/ScopedLogger.js +70 -0
  37. package/lib/module/ScopedLogger.js.map +1 -0
  38. package/lib/module/config.js +23 -0
  39. package/lib/module/config.js.map +1 -0
  40. package/lib/module/destinations/Batcher.js +647 -0
  41. package/lib/module/destinations/Batcher.js.map +1 -0
  42. package/lib/module/destinations/ConsoleDestination.js +51 -0
  43. package/lib/module/destinations/ConsoleDestination.js.map +1 -0
  44. package/lib/module/destinations/FileDestination.js +360 -0
  45. package/lib/module/destinations/FileDestination.js.map +1 -0
  46. package/lib/module/destinations/NativeConsoleDestination.js +170 -0
  47. package/lib/module/destinations/NativeConsoleDestination.js.map +1 -0
  48. package/lib/module/destinations/types.js +4 -0
  49. package/lib/module/destinations/types.js.map +1 -0
  50. package/lib/module/formatters/DefaultFormatter.js +136 -0
  51. package/lib/module/formatters/DefaultFormatter.js.map +1 -0
  52. package/lib/module/formatters/JsonLinesFormatter.js +162 -0
  53. package/lib/module/formatters/JsonLinesFormatter.js.map +1 -0
  54. package/lib/module/formatters/timestamp.js +15 -0
  55. package/lib/module/formatters/timestamp.js.map +1 -0
  56. package/lib/module/formatters/types.js +4 -0
  57. package/lib/module/formatters/types.js.map +1 -0
  58. package/lib/module/index.js +31 -0
  59. package/lib/module/index.js.map +1 -0
  60. package/lib/module/integrations/appState.js +81 -0
  61. package/lib/module/integrations/appState.js.map +1 -0
  62. package/lib/module/integrations/errorHandler.js +166 -0
  63. package/lib/module/integrations/errorHandler.js.map +1 -0
  64. package/lib/module/integrations/sanitizeError.js +238 -0
  65. package/lib/module/integrations/sanitizeError.js.map +1 -0
  66. package/lib/module/levels.js +35 -0
  67. package/lib/module/levels.js.map +1 -0
  68. package/lib/module/metadata.js +52 -0
  69. package/lib/module/metadata.js.map +1 -0
  70. package/lib/module/package.json +1 -0
  71. package/lib/module/privacy.js +349 -0
  72. package/lib/module/privacy.js.map +1 -0
  73. package/lib/module/specs/FileSink.nitro.js +4 -0
  74. package/lib/module/specs/FileSink.nitro.js.map +1 -0
  75. package/lib/module/specs/NativeConsoleSink.nitro.js +4 -0
  76. package/lib/module/specs/NativeConsoleSink.nitro.js.map +1 -0
  77. package/lib/module/types.js +4 -0
  78. package/lib/module/types.js.map +1 -0
  79. package/lib/module/utf8.js +42 -0
  80. package/lib/module/utf8.js.map +1 -0
  81. package/lib/typescript/package.json +1 -0
  82. package/lib/typescript/src/Logger.d.ts +122 -0
  83. package/lib/typescript/src/Logger.d.ts.map +1 -0
  84. package/lib/typescript/src/ScopedLogger.d.ts +36 -0
  85. package/lib/typescript/src/ScopedLogger.d.ts.map +1 -0
  86. package/lib/typescript/src/config.d.ts +12 -0
  87. package/lib/typescript/src/config.d.ts.map +1 -0
  88. package/lib/typescript/src/destinations/Batcher.d.ts +244 -0
  89. package/lib/typescript/src/destinations/Batcher.d.ts.map +1 -0
  90. package/lib/typescript/src/destinations/ConsoleDestination.d.ts +27 -0
  91. package/lib/typescript/src/destinations/ConsoleDestination.d.ts.map +1 -0
  92. package/lib/typescript/src/destinations/FileDestination.d.ts +200 -0
  93. package/lib/typescript/src/destinations/FileDestination.d.ts.map +1 -0
  94. package/lib/typescript/src/destinations/NativeConsoleDestination.d.ts +86 -0
  95. package/lib/typescript/src/destinations/NativeConsoleDestination.d.ts.map +1 -0
  96. package/lib/typescript/src/destinations/types.d.ts +19 -0
  97. package/lib/typescript/src/destinations/types.d.ts.map +1 -0
  98. package/lib/typescript/src/formatters/DefaultFormatter.d.ts +22 -0
  99. package/lib/typescript/src/formatters/DefaultFormatter.d.ts.map +1 -0
  100. package/lib/typescript/src/formatters/JsonLinesFormatter.d.ts +73 -0
  101. package/lib/typescript/src/formatters/JsonLinesFormatter.d.ts.map +1 -0
  102. package/lib/typescript/src/formatters/timestamp.d.ts +6 -0
  103. package/lib/typescript/src/formatters/timestamp.d.ts.map +1 -0
  104. package/lib/typescript/src/formatters/types.d.ts +27 -0
  105. package/lib/typescript/src/formatters/types.d.ts.map +1 -0
  106. package/lib/typescript/src/index.d.ts +34 -0
  107. package/lib/typescript/src/index.d.ts.map +1 -0
  108. package/lib/typescript/src/integrations/appState.d.ts +33 -0
  109. package/lib/typescript/src/integrations/appState.d.ts.map +1 -0
  110. package/lib/typescript/src/integrations/errorHandler.d.ts +55 -0
  111. package/lib/typescript/src/integrations/errorHandler.d.ts.map +1 -0
  112. package/lib/typescript/src/integrations/sanitizeError.d.ts +89 -0
  113. package/lib/typescript/src/integrations/sanitizeError.d.ts.map +1 -0
  114. package/lib/typescript/src/levels.d.ts +9 -0
  115. package/lib/typescript/src/levels.d.ts.map +1 -0
  116. package/lib/typescript/src/metadata.d.ts +23 -0
  117. package/lib/typescript/src/metadata.d.ts.map +1 -0
  118. package/lib/typescript/src/privacy.d.ts +103 -0
  119. package/lib/typescript/src/privacy.d.ts.map +1 -0
  120. package/lib/typescript/src/specs/FileSink.nitro.d.ts +131 -0
  121. package/lib/typescript/src/specs/FileSink.nitro.d.ts.map +1 -0
  122. package/lib/typescript/src/specs/NativeConsoleSink.nitro.d.ts +21 -0
  123. package/lib/typescript/src/specs/NativeConsoleSink.nitro.d.ts.map +1 -0
  124. package/lib/typescript/src/types.d.ts +37 -0
  125. package/lib/typescript/src/types.d.ts.map +1 -0
  126. package/lib/typescript/src/utf8.d.ts +15 -0
  127. package/lib/typescript/src/utf8.d.ts.map +1 -0
  128. package/nitro.json +33 -0
  129. package/nitrogen/generated/android/c++/JAppendResult.hpp +79 -0
  130. package/nitrogen/generated/android/c++/JClearOutcome.hpp +88 -0
  131. package/nitrogen/generated/android/c++/JFlushOutcome.hpp +81 -0
  132. package/nitrogen/generated/android/c++/JHybridFileSinkSpec.cpp +120 -0
  133. package/nitrogen/generated/android/c++/JHybridFileSinkSpec.hpp +69 -0
  134. package/nitrogen/generated/android/c++/JHybridNativeConsoleSinkSpec.cpp +71 -0
  135. package/nitrogen/generated/android/c++/JHybridNativeConsoleSinkSpec.hpp +64 -0
  136. package/nitrogen/generated/android/c++/JRejectReason.hpp +64 -0
  137. package/nitrogen/generated/android/c++/JRotationConfig.hpp +77 -0
  138. package/nitrogen/generated/android/c++/JSinkStatus.hpp +69 -0
  139. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/AppendResult.kt +76 -0
  140. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/ClearOutcome.kt +66 -0
  141. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/FlushOutcome.kt +81 -0
  142. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/HybridFileSinkSpec.kt +80 -0
  143. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/HybridNativeConsoleSinkSpec.kt +58 -0
  144. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/RejectReason.kt +25 -0
  145. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/RotationConfig.kt +76 -0
  146. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/SinkStatus.kt +66 -0
  147. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/nitrologgerOnLoad.kt +35 -0
  148. package/nitrogen/generated/android/nitrologger+autolinking.cmake +83 -0
  149. package/nitrogen/generated/android/nitrologger+autolinking.gradle +27 -0
  150. package/nitrogen/generated/android/nitrologgerOnLoad.cpp +70 -0
  151. package/nitrogen/generated/android/nitrologgerOnLoad.hpp +34 -0
  152. package/nitrogen/generated/ios/NitroLogger+autolinking.rb +62 -0
  153. package/nitrogen/generated/ios/NitroLogger-Swift-Cxx-Bridge.cpp +50 -0
  154. package/nitrogen/generated/ios/NitroLogger-Swift-Cxx-Bridge.hpp +216 -0
  155. package/nitrogen/generated/ios/NitroLogger-Swift-Cxx-Umbrella.hpp +69 -0
  156. package/nitrogen/generated/ios/NitroLoggerAutolinking.mm +41 -0
  157. package/nitrogen/generated/ios/NitroLoggerAutolinking.swift +38 -0
  158. package/nitrogen/generated/ios/c++/HybridFileSinkSpecSwift.cpp +11 -0
  159. package/nitrogen/generated/ios/c++/HybridFileSinkSpecSwift.hpp +150 -0
  160. package/nitrogen/generated/ios/c++/HybridNativeConsoleSinkSpecSwift.cpp +11 -0
  161. package/nitrogen/generated/ios/c++/HybridNativeConsoleSinkSpecSwift.hpp +87 -0
  162. package/nitrogen/generated/ios/swift/AppendResult.swift +60 -0
  163. package/nitrogen/generated/ios/swift/ClearOutcome.swift +50 -0
  164. package/nitrogen/generated/ios/swift/FlushOutcome.swift +59 -0
  165. package/nitrogen/generated/ios/swift/HybridFileSinkSpec.swift +61 -0
  166. package/nitrogen/generated/ios/swift/HybridFileSinkSpec_cxx.swift +227 -0
  167. package/nitrogen/generated/ios/swift/HybridNativeConsoleSinkSpec.swift +56 -0
  168. package/nitrogen/generated/ios/swift/HybridNativeConsoleSinkSpec_cxx.swift +148 -0
  169. package/nitrogen/generated/ios/swift/RejectReason.swift +48 -0
  170. package/nitrogen/generated/ios/swift/RotationConfig.swift +93 -0
  171. package/nitrogen/generated/ios/swift/SinkStatus.swift +44 -0
  172. package/nitrogen/generated/shared/c++/AppendResult.hpp +105 -0
  173. package/nitrogen/generated/shared/c++/ClearOutcome.hpp +96 -0
  174. package/nitrogen/generated/shared/c++/FlushOutcome.hpp +107 -0
  175. package/nitrogen/generated/shared/c++/HybridFileSinkSpec.cpp +28 -0
  176. package/nitrogen/generated/shared/c++/HybridFileSinkSpec.hpp +84 -0
  177. package/nitrogen/generated/shared/c++/HybridNativeConsoleSinkSpec.cpp +22 -0
  178. package/nitrogen/generated/shared/c++/HybridNativeConsoleSinkSpec.hpp +64 -0
  179. package/nitrogen/generated/shared/c++/RejectReason.hpp +84 -0
  180. package/nitrogen/generated/shared/c++/RotationConfig.hpp +103 -0
  181. package/nitrogen/generated/shared/c++/SinkStatus.hpp +95 -0
  182. package/package.json +151 -0
  183. package/src/Logger.ts +417 -0
  184. package/src/ScopedLogger.ts +94 -0
  185. package/src/config.ts +25 -0
  186. package/src/destinations/Batcher.ts +805 -0
  187. package/src/destinations/ConsoleDestination.ts +60 -0
  188. package/src/destinations/FileDestination.ts +473 -0
  189. package/src/destinations/NativeConsoleDestination.ts +220 -0
  190. package/src/destinations/types.ts +19 -0
  191. package/src/formatters/DefaultFormatter.ts +150 -0
  192. package/src/formatters/JsonLinesFormatter.ts +195 -0
  193. package/src/formatters/timestamp.ts +12 -0
  194. package/src/formatters/types.ts +29 -0
  195. package/src/index.tsx +106 -0
  196. package/src/integrations/appState.ts +111 -0
  197. package/src/integrations/errorHandler.ts +223 -0
  198. package/src/integrations/sanitizeError.ts +287 -0
  199. package/src/levels.ts +35 -0
  200. package/src/metadata.ts +52 -0
  201. package/src/privacy.ts +389 -0
  202. package/src/specs/FileSink.nitro.ts +144 -0
  203. package/src/specs/NativeConsoleSink.nitro.ts +21 -0
  204. package/src/types.ts +45 -0
  205. package/src/utf8.ts +39 -0
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// RejectReason.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /**
9
+ * Represents the JS union `RejectReason`, backed by a C++ enum.
10
+ */
11
+ public typealias RejectReason = margelo.nitro.nitrologger.RejectReason
12
+
13
+ public extension RejectReason {
14
+ /**
15
+ * Get a RejectReason for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "full":
21
+ self = .full
22
+ case "staleGeneration":
23
+ self = .stalegeneration
24
+ case "closed":
25
+ self = .closed
26
+ case "failed":
27
+ self = .failed
28
+ default:
29
+ return nil
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Get the String value this RejectReason represents.
35
+ */
36
+ var stringValue: String {
37
+ switch self {
38
+ case .full:
39
+ return "full"
40
+ case .stalegeneration:
41
+ return "staleGeneration"
42
+ case .closed:
43
+ return "closed"
44
+ case .failed:
45
+ return "failed"
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,93 @@
1
+ ///
2
+ /// RotationConfig.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `RotationConfig`, backed by a C++ struct.
12
+ */
13
+ public typealias RotationConfig = margelo.nitro.nitrologger.RotationConfig
14
+
15
+ public extension RotationConfig {
16
+ private typealias bridge = margelo.nitro.nitrologger.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `RotationConfig`.
20
+ */
21
+ init(maxFileSizeBytes: Double, maxArchivedFilesCount: Double, maxFileAgeSeconds: Double?, compressArchives: Bool, maxArchiveAgeSeconds: Double?, maxTotalLogBytes: Double?) {
22
+ self.init(maxFileSizeBytes, maxArchivedFilesCount, { () -> bridge.std__optional_double_ in
23
+ if let __unwrappedValue = maxFileAgeSeconds {
24
+ return bridge.create_std__optional_double_(__unwrappedValue)
25
+ } else {
26
+ return .init()
27
+ }
28
+ }(), compressArchives, { () -> bridge.std__optional_double_ in
29
+ if let __unwrappedValue = maxArchiveAgeSeconds {
30
+ return bridge.create_std__optional_double_(__unwrappedValue)
31
+ } else {
32
+ return .init()
33
+ }
34
+ }(), { () -> bridge.std__optional_double_ in
35
+ if let __unwrappedValue = maxTotalLogBytes {
36
+ return bridge.create_std__optional_double_(__unwrappedValue)
37
+ } else {
38
+ return .init()
39
+ }
40
+ }())
41
+ }
42
+
43
+ @inline(__always)
44
+ var maxFileSizeBytes: Double {
45
+ return self.__maxFileSizeBytes
46
+ }
47
+
48
+ @inline(__always)
49
+ var maxArchivedFilesCount: Double {
50
+ return self.__maxArchivedFilesCount
51
+ }
52
+
53
+ @inline(__always)
54
+ var maxFileAgeSeconds: Double? {
55
+ return { () -> Double? in
56
+ if bridge.has_value_std__optional_double_(self.__maxFileAgeSeconds) {
57
+ let __unwrapped = bridge.get_std__optional_double_(self.__maxFileAgeSeconds)
58
+ return __unwrapped
59
+ } else {
60
+ return nil
61
+ }
62
+ }()
63
+ }
64
+
65
+ @inline(__always)
66
+ var compressArchives: Bool {
67
+ return self.__compressArchives
68
+ }
69
+
70
+ @inline(__always)
71
+ var maxArchiveAgeSeconds: Double? {
72
+ return { () -> Double? in
73
+ if bridge.has_value_std__optional_double_(self.__maxArchiveAgeSeconds) {
74
+ let __unwrapped = bridge.get_std__optional_double_(self.__maxArchiveAgeSeconds)
75
+ return __unwrapped
76
+ } else {
77
+ return nil
78
+ }
79
+ }()
80
+ }
81
+
82
+ @inline(__always)
83
+ var maxTotalLogBytes: Double? {
84
+ return { () -> Double? in
85
+ if bridge.has_value_std__optional_double_(self.__maxTotalLogBytes) {
86
+ let __unwrapped = bridge.get_std__optional_double_(self.__maxTotalLogBytes)
87
+ return __unwrapped
88
+ } else {
89
+ return nil
90
+ }
91
+ }()
92
+ }
93
+ }
@@ -0,0 +1,44 @@
1
+ ///
2
+ /// SinkStatus.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `SinkStatus`, backed by a C++ struct.
12
+ */
13
+ public typealias SinkStatus = margelo.nitro.nitrologger.SinkStatus
14
+
15
+ public extension SinkStatus {
16
+ private typealias bridge = margelo.nitro.nitrologger.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `SinkStatus`.
20
+ */
21
+ init(queuedBytes: Double, lostBytes: Double, lostEntries: Double, degraded: Double) {
22
+ self.init(queuedBytes, lostBytes, lostEntries, degraded)
23
+ }
24
+
25
+ @inline(__always)
26
+ var queuedBytes: Double {
27
+ return self.__queuedBytes
28
+ }
29
+
30
+ @inline(__always)
31
+ var lostBytes: Double {
32
+ return self.__lostBytes
33
+ }
34
+
35
+ @inline(__always)
36
+ var lostEntries: Double {
37
+ return self.__lostEntries
38
+ }
39
+
40
+ @inline(__always)
41
+ var degraded: Double {
42
+ return self.__degraded
43
+ }
44
+ }
@@ -0,0 +1,105 @@
1
+ ///
2
+ /// AppendResult.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `RejectReason` to properly resolve imports.
32
+ namespace margelo::nitro::nitrologger { enum class RejectReason; }
33
+
34
+ #include "RejectReason.hpp"
35
+ #include <optional>
36
+
37
+ namespace margelo::nitro::nitrologger {
38
+
39
+ /**
40
+ * A struct which can be represented as a JavaScript object (AppendResult).
41
+ */
42
+ struct AppendResult final {
43
+ public:
44
+ bool accepted SWIFT_PRIVATE;
45
+ std::optional<RejectReason> rejectReason SWIFT_PRIVATE;
46
+ double queuedBytes SWIFT_PRIVATE;
47
+ double lostBytes SWIFT_PRIVATE;
48
+ double lostEntries SWIFT_PRIVATE;
49
+ double degraded SWIFT_PRIVATE;
50
+
51
+ public:
52
+ AppendResult() = default;
53
+ explicit AppendResult(bool accepted, std::optional<RejectReason> rejectReason, double queuedBytes, double lostBytes, double lostEntries, double degraded): accepted(accepted), rejectReason(rejectReason), queuedBytes(queuedBytes), lostBytes(lostBytes), lostEntries(lostEntries), degraded(degraded) {}
54
+
55
+ public:
56
+ friend bool operator==(const AppendResult& lhs, const AppendResult& rhs) = default;
57
+ };
58
+
59
+ } // namespace margelo::nitro::nitrologger
60
+
61
+ namespace margelo::nitro {
62
+
63
+ // C++ AppendResult <> JS AppendResult (object)
64
+ template <>
65
+ struct JSIConverter<margelo::nitro::nitrologger::AppendResult> final {
66
+ static inline margelo::nitro::nitrologger::AppendResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
67
+ jsi::Object obj = arg.asObject(runtime);
68
+ return margelo::nitro::nitrologger::AppendResult(
69
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accepted"))),
70
+ JSIConverter<std::optional<margelo::nitro::nitrologger::RejectReason>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rejectReason"))),
71
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queuedBytes"))),
72
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostBytes"))),
73
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostEntries"))),
74
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "degraded")))
75
+ );
76
+ }
77
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrologger::AppendResult& arg) {
78
+ jsi::Object obj(runtime);
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "accepted"), JSIConverter<bool>::toJSI(runtime, arg.accepted));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "rejectReason"), JSIConverter<std::optional<margelo::nitro::nitrologger::RejectReason>>::toJSI(runtime, arg.rejectReason));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "queuedBytes"), JSIConverter<double>::toJSI(runtime, arg.queuedBytes));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "lostBytes"), JSIConverter<double>::toJSI(runtime, arg.lostBytes));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "lostEntries"), JSIConverter<double>::toJSI(runtime, arg.lostEntries));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "degraded"), JSIConverter<double>::toJSI(runtime, arg.degraded));
85
+ return obj;
86
+ }
87
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
88
+ if (!value.isObject()) {
89
+ return false;
90
+ }
91
+ jsi::Object obj = value.getObject(runtime);
92
+ if (!nitro::isPlainObject(runtime, obj)) {
93
+ return false;
94
+ }
95
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accepted")))) return false;
96
+ if (!JSIConverter<std::optional<margelo::nitro::nitrologger::RejectReason>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rejectReason")))) return false;
97
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queuedBytes")))) return false;
98
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostBytes")))) return false;
99
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostEntries")))) return false;
100
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "degraded")))) return false;
101
+ return true;
102
+ }
103
+ };
104
+
105
+ } // namespace margelo::nitro
@@ -0,0 +1,96 @@
1
+ ///
2
+ /// ClearOutcome.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+ #include <vector>
35
+
36
+ namespace margelo::nitro::nitrologger {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (ClearOutcome).
40
+ */
41
+ struct ClearOutcome final {
42
+ public:
43
+ double deletedCount SWIFT_PRIVATE;
44
+ std::vector<std::string> failedPaths SWIFT_PRIVATE;
45
+ bool durable SWIFT_PRIVATE;
46
+ bool rebound SWIFT_PRIVATE;
47
+
48
+ public:
49
+ ClearOutcome() = default;
50
+ explicit ClearOutcome(double deletedCount, std::vector<std::string> failedPaths, bool durable, bool rebound): deletedCount(deletedCount), failedPaths(failedPaths), durable(durable), rebound(rebound) {}
51
+
52
+ public:
53
+ friend bool operator==(const ClearOutcome& lhs, const ClearOutcome& rhs) = default;
54
+ };
55
+
56
+ } // namespace margelo::nitro::nitrologger
57
+
58
+ namespace margelo::nitro {
59
+
60
+ // C++ ClearOutcome <> JS ClearOutcome (object)
61
+ template <>
62
+ struct JSIConverter<margelo::nitro::nitrologger::ClearOutcome> final {
63
+ static inline margelo::nitro::nitrologger::ClearOutcome fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
64
+ jsi::Object obj = arg.asObject(runtime);
65
+ return margelo::nitro::nitrologger::ClearOutcome(
66
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deletedCount"))),
67
+ JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "failedPaths"))),
68
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durable"))),
69
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rebound")))
70
+ );
71
+ }
72
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrologger::ClearOutcome& arg) {
73
+ jsi::Object obj(runtime);
74
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "deletedCount"), JSIConverter<double>::toJSI(runtime, arg.deletedCount));
75
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "failedPaths"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.failedPaths));
76
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "durable"), JSIConverter<bool>::toJSI(runtime, arg.durable));
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "rebound"), JSIConverter<bool>::toJSI(runtime, arg.rebound));
78
+ return obj;
79
+ }
80
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
81
+ if (!value.isObject()) {
82
+ return false;
83
+ }
84
+ jsi::Object obj = value.getObject(runtime);
85
+ if (!nitro::isPlainObject(runtime, obj)) {
86
+ return false;
87
+ }
88
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deletedCount")))) return false;
89
+ if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "failedPaths")))) return false;
90
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durable")))) return false;
91
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rebound")))) return false;
92
+ return true;
93
+ }
94
+ };
95
+
96
+ } // namespace margelo::nitro
@@ -0,0 +1,107 @@
1
+ ///
2
+ /// FlushOutcome.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::nitrologger {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (FlushOutcome).
39
+ */
40
+ struct FlushOutcome final {
41
+ public:
42
+ bool durable SWIFT_PRIVATE;
43
+ bool timedOut SWIFT_PRIVATE;
44
+ double pendingBytes SWIFT_PRIVATE;
45
+ double queuedBytes SWIFT_PRIVATE;
46
+ double lostBytes SWIFT_PRIVATE;
47
+ double lostEntries SWIFT_PRIVATE;
48
+ double degraded SWIFT_PRIVATE;
49
+
50
+ public:
51
+ FlushOutcome() = default;
52
+ explicit FlushOutcome(bool durable, bool timedOut, double pendingBytes, double queuedBytes, double lostBytes, double lostEntries, double degraded): durable(durable), timedOut(timedOut), pendingBytes(pendingBytes), queuedBytes(queuedBytes), lostBytes(lostBytes), lostEntries(lostEntries), degraded(degraded) {}
53
+
54
+ public:
55
+ friend bool operator==(const FlushOutcome& lhs, const FlushOutcome& rhs) = default;
56
+ };
57
+
58
+ } // namespace margelo::nitro::nitrologger
59
+
60
+ namespace margelo::nitro {
61
+
62
+ // C++ FlushOutcome <> JS FlushOutcome (object)
63
+ template <>
64
+ struct JSIConverter<margelo::nitro::nitrologger::FlushOutcome> final {
65
+ static inline margelo::nitro::nitrologger::FlushOutcome fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
66
+ jsi::Object obj = arg.asObject(runtime);
67
+ return margelo::nitro::nitrologger::FlushOutcome(
68
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durable"))),
69
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timedOut"))),
70
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pendingBytes"))),
71
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queuedBytes"))),
72
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostBytes"))),
73
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostEntries"))),
74
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "degraded")))
75
+ );
76
+ }
77
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitrologger::FlushOutcome& arg) {
78
+ jsi::Object obj(runtime);
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "durable"), JSIConverter<bool>::toJSI(runtime, arg.durable));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "timedOut"), JSIConverter<bool>::toJSI(runtime, arg.timedOut));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "pendingBytes"), JSIConverter<double>::toJSI(runtime, arg.pendingBytes));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "queuedBytes"), JSIConverter<double>::toJSI(runtime, arg.queuedBytes));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "lostBytes"), JSIConverter<double>::toJSI(runtime, arg.lostBytes));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "lostEntries"), JSIConverter<double>::toJSI(runtime, arg.lostEntries));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "degraded"), JSIConverter<double>::toJSI(runtime, arg.degraded));
86
+ return obj;
87
+ }
88
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
89
+ if (!value.isObject()) {
90
+ return false;
91
+ }
92
+ jsi::Object obj = value.getObject(runtime);
93
+ if (!nitro::isPlainObject(runtime, obj)) {
94
+ return false;
95
+ }
96
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durable")))) return false;
97
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timedOut")))) return false;
98
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pendingBytes")))) return false;
99
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queuedBytes")))) return false;
100
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostBytes")))) return false;
101
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lostEntries")))) return false;
102
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "degraded")))) return false;
103
+ return true;
104
+ }
105
+ };
106
+
107
+ } // namespace margelo::nitro
@@ -0,0 +1,28 @@
1
+ ///
2
+ /// HybridFileSinkSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridFileSinkSpec.hpp"
9
+
10
+ namespace margelo::nitro::nitrologger {
11
+
12
+ void HybridFileSinkSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("defaultLogDirectory", &HybridFileSinkSpec::getDefaultLogDirectory);
18
+ prototype.registerHybridMethod("open", &HybridFileSinkSpec::open);
19
+ prototype.registerHybridMethod("appendBatch", &HybridFileSinkSpec::appendBatch);
20
+ prototype.registerHybridMethod("getStatus", &HybridFileSinkSpec::getStatus);
21
+ prototype.registerHybridMethod("flush", &HybridFileSinkSpec::flush);
22
+ prototype.registerHybridMethod("close", &HybridFileSinkSpec::close);
23
+ prototype.registerHybridMethod("getLogFilePaths", &HybridFileSinkSpec::getLogFilePaths);
24
+ prototype.registerHybridMethod("clearLogs", &HybridFileSinkSpec::clearLogs);
25
+ });
26
+ }
27
+
28
+ } // namespace margelo::nitro::nitrologger
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// HybridFileSinkSpec.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `RotationConfig` to properly resolve imports.
17
+ namespace margelo::nitro::nitrologger { struct RotationConfig; }
18
+ // Forward declaration of `AppendResult` to properly resolve imports.
19
+ namespace margelo::nitro::nitrologger { struct AppendResult; }
20
+ // Forward declaration of `SinkStatus` to properly resolve imports.
21
+ namespace margelo::nitro::nitrologger { struct SinkStatus; }
22
+ // Forward declaration of `FlushOutcome` to properly resolve imports.
23
+ namespace margelo::nitro::nitrologger { struct FlushOutcome; }
24
+ // Forward declaration of `ClearOutcome` to properly resolve imports.
25
+ namespace margelo::nitro::nitrologger { struct ClearOutcome; }
26
+
27
+ #include <string>
28
+ #include "RotationConfig.hpp"
29
+ #include <optional>
30
+ #include "AppendResult.hpp"
31
+ #include "SinkStatus.hpp"
32
+ #include "FlushOutcome.hpp"
33
+ #include <vector>
34
+ #include "ClearOutcome.hpp"
35
+
36
+ namespace margelo::nitro::nitrologger {
37
+
38
+ using namespace margelo::nitro;
39
+
40
+ /**
41
+ * An abstract base class for `FileSink`
42
+ * Inherit this class to create instances of `HybridFileSinkSpec` in C++.
43
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
44
+ * @example
45
+ * ```cpp
46
+ * class HybridFileSink: public HybridFileSinkSpec {
47
+ * public:
48
+ * HybridFileSink(...): HybridObject(TAG) { ... }
49
+ * // ...
50
+ * };
51
+ * ```
52
+ */
53
+ class HybridFileSinkSpec: public virtual HybridObject {
54
+ public:
55
+ // Constructor
56
+ explicit HybridFileSinkSpec(): HybridObject(TAG) { }
57
+
58
+ // Destructor
59
+ ~HybridFileSinkSpec() override = default;
60
+
61
+ public:
62
+ // Properties
63
+ virtual std::string getDefaultLogDirectory() = 0;
64
+
65
+ public:
66
+ // Methods
67
+ virtual void open(const std::string& path, const std::optional<RotationConfig>& rotation, std::optional<bool> lineFramed) = 0;
68
+ virtual AppendResult appendBatch(const std::string& batch, double entryCount) = 0;
69
+ virtual SinkStatus getStatus() = 0;
70
+ virtual FlushOutcome flush(double deadlineMs) = 0;
71
+ virtual FlushOutcome close(double deadlineMs) = 0;
72
+ virtual std::vector<std::string> getLogFilePaths() = 0;
73
+ virtual ClearOutcome clearLogs(double deadlineMs) = 0;
74
+
75
+ protected:
76
+ // Hybrid Setup
77
+ void loadHybridMethods() override;
78
+
79
+ protected:
80
+ // Tag for logging
81
+ static constexpr auto TAG = "FileSink";
82
+ };
83
+
84
+ } // namespace margelo::nitro::nitrologger
@@ -0,0 +1,22 @@
1
+ ///
2
+ /// HybridNativeConsoleSinkSpec.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "HybridNativeConsoleSinkSpec.hpp"
9
+
10
+ namespace margelo::nitro::nitrologger {
11
+
12
+ void HybridNativeConsoleSinkSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridMethod("install", &HybridNativeConsoleSinkSpec::install);
18
+ prototype.registerHybridMethod("logBatch", &HybridNativeConsoleSinkSpec::logBatch);
19
+ });
20
+ }
21
+
22
+ } // namespace margelo::nitro::nitrologger