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.
- package/LICENSE +20 -0
- package/NitroLogger.podspec +29 -0
- package/README.md +214 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +124 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/AndroidPlatformIo.kt +100 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/HybridFileSink.kt +292 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/HybridNativeConsoleSink.kt +23 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/LogFileWriter.kt +1328 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/LogRotationPolicy.kt +186 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/LogSecureFile.kt +80 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/LogWriterRegistry.kt +420 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/NativeConsoleWriter.kt +237 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/NitroLoggerPackage.kt +22 -0
- package/android/src/main/java/com/margelo/nitro/nitrologger/PlatformIo.kt +165 -0
- package/docs/PARITY.md +330 -0
- package/docs/PRIVACY.md +341 -0
- package/eslint-plugin/README.md +238 -0
- package/eslint-plugin/index.js +62 -0
- package/eslint-plugin/rules/literal-subsystem.js +102 -0
- package/eslint-plugin/rules/no-computed-metadata-key.js +174 -0
- package/eslint-plugin/rules/no-derived-correlation.js +171 -0
- package/eslint-plugin/rules/no-dynamic-message.js +60 -0
- package/eslint-plugin/shared.js +1948 -0
- package/ios/Gzip.swift +203 -0
- package/ios/HybridFileSink.swift +291 -0
- package/ios/HybridNativeConsoleSink.swift +20 -0
- package/ios/LogFileWriter.swift +1280 -0
- package/ios/LogSecureFile.swift +296 -0
- package/ios/LogWriterRegistry.swift +444 -0
- package/ios/NativeConsoleWriter.swift +180 -0
- package/lib/module/Logger.js +381 -0
- package/lib/module/Logger.js.map +1 -0
- package/lib/module/ScopedLogger.js +70 -0
- package/lib/module/ScopedLogger.js.map +1 -0
- package/lib/module/config.js +23 -0
- package/lib/module/config.js.map +1 -0
- package/lib/module/destinations/Batcher.js +647 -0
- package/lib/module/destinations/Batcher.js.map +1 -0
- package/lib/module/destinations/ConsoleDestination.js +51 -0
- package/lib/module/destinations/ConsoleDestination.js.map +1 -0
- package/lib/module/destinations/FileDestination.js +360 -0
- package/lib/module/destinations/FileDestination.js.map +1 -0
- package/lib/module/destinations/NativeConsoleDestination.js +170 -0
- package/lib/module/destinations/NativeConsoleDestination.js.map +1 -0
- package/lib/module/destinations/types.js +4 -0
- package/lib/module/destinations/types.js.map +1 -0
- package/lib/module/formatters/DefaultFormatter.js +136 -0
- package/lib/module/formatters/DefaultFormatter.js.map +1 -0
- package/lib/module/formatters/JsonLinesFormatter.js +162 -0
- package/lib/module/formatters/JsonLinesFormatter.js.map +1 -0
- package/lib/module/formatters/timestamp.js +15 -0
- package/lib/module/formatters/timestamp.js.map +1 -0
- package/lib/module/formatters/types.js +4 -0
- package/lib/module/formatters/types.js.map +1 -0
- package/lib/module/index.js +31 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/integrations/appState.js +81 -0
- package/lib/module/integrations/appState.js.map +1 -0
- package/lib/module/integrations/errorHandler.js +166 -0
- package/lib/module/integrations/errorHandler.js.map +1 -0
- package/lib/module/integrations/sanitizeError.js +238 -0
- package/lib/module/integrations/sanitizeError.js.map +1 -0
- package/lib/module/levels.js +35 -0
- package/lib/module/levels.js.map +1 -0
- package/lib/module/metadata.js +52 -0
- package/lib/module/metadata.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/privacy.js +349 -0
- package/lib/module/privacy.js.map +1 -0
- package/lib/module/specs/FileSink.nitro.js +4 -0
- package/lib/module/specs/FileSink.nitro.js.map +1 -0
- package/lib/module/specs/NativeConsoleSink.nitro.js +4 -0
- package/lib/module/specs/NativeConsoleSink.nitro.js.map +1 -0
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utf8.js +42 -0
- package/lib/module/utf8.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Logger.d.ts +122 -0
- package/lib/typescript/src/Logger.d.ts.map +1 -0
- package/lib/typescript/src/ScopedLogger.d.ts +36 -0
- package/lib/typescript/src/ScopedLogger.d.ts.map +1 -0
- package/lib/typescript/src/config.d.ts +12 -0
- package/lib/typescript/src/config.d.ts.map +1 -0
- package/lib/typescript/src/destinations/Batcher.d.ts +244 -0
- package/lib/typescript/src/destinations/Batcher.d.ts.map +1 -0
- package/lib/typescript/src/destinations/ConsoleDestination.d.ts +27 -0
- package/lib/typescript/src/destinations/ConsoleDestination.d.ts.map +1 -0
- package/lib/typescript/src/destinations/FileDestination.d.ts +200 -0
- package/lib/typescript/src/destinations/FileDestination.d.ts.map +1 -0
- package/lib/typescript/src/destinations/NativeConsoleDestination.d.ts +86 -0
- package/lib/typescript/src/destinations/NativeConsoleDestination.d.ts.map +1 -0
- package/lib/typescript/src/destinations/types.d.ts +19 -0
- package/lib/typescript/src/destinations/types.d.ts.map +1 -0
- package/lib/typescript/src/formatters/DefaultFormatter.d.ts +22 -0
- package/lib/typescript/src/formatters/DefaultFormatter.d.ts.map +1 -0
- package/lib/typescript/src/formatters/JsonLinesFormatter.d.ts +73 -0
- package/lib/typescript/src/formatters/JsonLinesFormatter.d.ts.map +1 -0
- package/lib/typescript/src/formatters/timestamp.d.ts +6 -0
- package/lib/typescript/src/formatters/timestamp.d.ts.map +1 -0
- package/lib/typescript/src/formatters/types.d.ts +27 -0
- package/lib/typescript/src/formatters/types.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +34 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/integrations/appState.d.ts +33 -0
- package/lib/typescript/src/integrations/appState.d.ts.map +1 -0
- package/lib/typescript/src/integrations/errorHandler.d.ts +55 -0
- package/lib/typescript/src/integrations/errorHandler.d.ts.map +1 -0
- package/lib/typescript/src/integrations/sanitizeError.d.ts +89 -0
- package/lib/typescript/src/integrations/sanitizeError.d.ts.map +1 -0
- package/lib/typescript/src/levels.d.ts +9 -0
- package/lib/typescript/src/levels.d.ts.map +1 -0
- package/lib/typescript/src/metadata.d.ts +23 -0
- package/lib/typescript/src/metadata.d.ts.map +1 -0
- package/lib/typescript/src/privacy.d.ts +103 -0
- package/lib/typescript/src/privacy.d.ts.map +1 -0
- package/lib/typescript/src/specs/FileSink.nitro.d.ts +131 -0
- package/lib/typescript/src/specs/FileSink.nitro.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeConsoleSink.nitro.d.ts +21 -0
- package/lib/typescript/src/specs/NativeConsoleSink.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +37 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/utf8.d.ts +15 -0
- package/lib/typescript/src/utf8.d.ts.map +1 -0
- package/nitro.json +33 -0
- package/nitrogen/generated/android/c++/JAppendResult.hpp +79 -0
- package/nitrogen/generated/android/c++/JClearOutcome.hpp +88 -0
- package/nitrogen/generated/android/c++/JFlushOutcome.hpp +81 -0
- package/nitrogen/generated/android/c++/JHybridFileSinkSpec.cpp +120 -0
- package/nitrogen/generated/android/c++/JHybridFileSinkSpec.hpp +69 -0
- package/nitrogen/generated/android/c++/JHybridNativeConsoleSinkSpec.cpp +71 -0
- package/nitrogen/generated/android/c++/JHybridNativeConsoleSinkSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JRejectReason.hpp +64 -0
- package/nitrogen/generated/android/c++/JRotationConfig.hpp +77 -0
- package/nitrogen/generated/android/c++/JSinkStatus.hpp +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/AppendResult.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/ClearOutcome.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/FlushOutcome.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/HybridFileSinkSpec.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/HybridNativeConsoleSinkSpec.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/RejectReason.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/RotationConfig.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/SinkStatus.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrologger/nitrologgerOnLoad.kt +35 -0
- package/nitrogen/generated/android/nitrologger+autolinking.cmake +83 -0
- package/nitrogen/generated/android/nitrologger+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitrologgerOnLoad.cpp +70 -0
- package/nitrogen/generated/android/nitrologgerOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/NitroLogger+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroLogger-Swift-Cxx-Bridge.cpp +50 -0
- package/nitrogen/generated/ios/NitroLogger-Swift-Cxx-Bridge.hpp +216 -0
- package/nitrogen/generated/ios/NitroLogger-Swift-Cxx-Umbrella.hpp +69 -0
- package/nitrogen/generated/ios/NitroLoggerAutolinking.mm +41 -0
- package/nitrogen/generated/ios/NitroLoggerAutolinking.swift +38 -0
- package/nitrogen/generated/ios/c++/HybridFileSinkSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridFileSinkSpecSwift.hpp +150 -0
- package/nitrogen/generated/ios/c++/HybridNativeConsoleSinkSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNativeConsoleSinkSpecSwift.hpp +87 -0
- package/nitrogen/generated/ios/swift/AppendResult.swift +60 -0
- package/nitrogen/generated/ios/swift/ClearOutcome.swift +50 -0
- package/nitrogen/generated/ios/swift/FlushOutcome.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridFileSinkSpec.swift +61 -0
- package/nitrogen/generated/ios/swift/HybridFileSinkSpec_cxx.swift +227 -0
- package/nitrogen/generated/ios/swift/HybridNativeConsoleSinkSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNativeConsoleSinkSpec_cxx.swift +148 -0
- package/nitrogen/generated/ios/swift/RejectReason.swift +48 -0
- package/nitrogen/generated/ios/swift/RotationConfig.swift +93 -0
- package/nitrogen/generated/ios/swift/SinkStatus.swift +44 -0
- package/nitrogen/generated/shared/c++/AppendResult.hpp +105 -0
- package/nitrogen/generated/shared/c++/ClearOutcome.hpp +96 -0
- package/nitrogen/generated/shared/c++/FlushOutcome.hpp +107 -0
- package/nitrogen/generated/shared/c++/HybridFileSinkSpec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridFileSinkSpec.hpp +84 -0
- package/nitrogen/generated/shared/c++/HybridNativeConsoleSinkSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNativeConsoleSinkSpec.hpp +64 -0
- package/nitrogen/generated/shared/c++/RejectReason.hpp +84 -0
- package/nitrogen/generated/shared/c++/RotationConfig.hpp +103 -0
- package/nitrogen/generated/shared/c++/SinkStatus.hpp +95 -0
- package/package.json +151 -0
- package/src/Logger.ts +417 -0
- package/src/ScopedLogger.ts +94 -0
- package/src/config.ts +25 -0
- package/src/destinations/Batcher.ts +805 -0
- package/src/destinations/ConsoleDestination.ts +60 -0
- package/src/destinations/FileDestination.ts +473 -0
- package/src/destinations/NativeConsoleDestination.ts +220 -0
- package/src/destinations/types.ts +19 -0
- package/src/formatters/DefaultFormatter.ts +150 -0
- package/src/formatters/JsonLinesFormatter.ts +195 -0
- package/src/formatters/timestamp.ts +12 -0
- package/src/formatters/types.ts +29 -0
- package/src/index.tsx +106 -0
- package/src/integrations/appState.ts +111 -0
- package/src/integrations/errorHandler.ts +223 -0
- package/src/integrations/sanitizeError.ts +287 -0
- package/src/levels.ts +35 -0
- package/src/metadata.ts +52 -0
- package/src/privacy.ts +389 -0
- package/src/specs/FileSink.nitro.ts +144 -0
- package/src/specs/NativeConsoleSink.nitro.ts +21 -0
- package/src/types.ts +45 -0
- package/src/utf8.ts +39 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileSink.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/FileSink.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iEAAiE;IACjE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wCAAwC;IACxC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,mEAAmE;IACnE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,iBAAiB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5E;;;;;;;;;GASG;AACH,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,0EAA0E;IAC1E,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;;;OAaG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAS,SAAQ,YAAY,CAAC;IAC7C,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IAErC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAE1E;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC;IAE7D,4EAA4E;IAC5E,SAAS,IAAI,UAAU,CAAC;IAExB,oDAAoD;IACpD,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC;IAExC,kEAAkE;IAClE,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC;IAExC,4CAA4C;IAC5C,eAAe,IAAI,MAAM,EAAE,CAAC;IAE5B;;;;;OAKG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC;CAC7C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
+
/**
|
|
3
|
+
* Routes pre-formatted lines to the platform's native log stream so JS logs
|
|
4
|
+
* interleave with native ones — os_log on iOS (Console.app / Xcode), logcat
|
|
5
|
+
* on Android.
|
|
6
|
+
*
|
|
7
|
+
* Levels cross as numeric codes 0–5 (verbose…todo) and map natively:
|
|
8
|
+
* verbose/debug → .debug, info → .info, warning → .default, error → .error,
|
|
9
|
+
* todo → .fault (iOS); Log.println priorities on Android.
|
|
10
|
+
*
|
|
11
|
+
* Batched like the file sink: one logBatch call per Batcher drain, parallel
|
|
12
|
+
* primitive arrays, no per-entry struct marshaling.
|
|
13
|
+
*/
|
|
14
|
+
export interface NativeConsoleSink extends HybridObject<{
|
|
15
|
+
ios: 'swift';
|
|
16
|
+
android: 'kotlin';
|
|
17
|
+
}> {
|
|
18
|
+
install(subsystem: string, category: string): void;
|
|
19
|
+
logBatch(levels: number[], messages: string[]): void;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=NativeConsoleSink.nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeConsoleSink.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeConsoleSink.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAkB,SAAQ,YAAY,CAAC;IACtD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACtD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PrivateValue, PublicValue } from './privacy.js';
|
|
2
|
+
export type { PrivateValue, PublicValue };
|
|
3
|
+
/** Severity levels, least to most severe. `todo` marks incomplete work and
|
|
4
|
+
* sorts highest so it always surfaces (SwiftLogger parity). */
|
|
5
|
+
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'todo';
|
|
6
|
+
/** Messages accept a thunk so hot-path callers can defer interpolation —
|
|
7
|
+
* the `@autoclosure` equivalent. The thunk is NOT invoked when the entry is
|
|
8
|
+
* filtered out or no destination is eligible. */
|
|
9
|
+
export type LazyMessage = string | (() => string);
|
|
10
|
+
/** The only value shapes the pipeline can render. */
|
|
11
|
+
export type LogPrimitive = string | number | boolean;
|
|
12
|
+
/** Metadata values: a bare primitive, whose visibility follows the privacy
|
|
13
|
+
* default, or one explicitly marked with `pub()` / `priv()`. */
|
|
14
|
+
export type LogValue = LogPrimitive | PublicValue | PrivateValue;
|
|
15
|
+
export type LogMetadata = Record<string, LogValue>;
|
|
16
|
+
/** Metadata after redaction — what formatters and destinations see. Privacy
|
|
17
|
+
* markers are unrepresentable here by construction: every value has already
|
|
18
|
+
* been resolved to a primitive or replaced by a placeholder. */
|
|
19
|
+
export type RedactedMetadata = Readonly<Record<string, LogPrimitive>>;
|
|
20
|
+
/** A single log event, post-redaction. Readonly and frozen at runtime: one
|
|
21
|
+
* entry fans out to every destination, so no destination may mutate what its
|
|
22
|
+
* siblings receive. No file/function/line: JS has no `#fileID`, and Hermes
|
|
23
|
+
* stack parsing is unreliable — subsystems are the filtering mechanism
|
|
24
|
+
* instead. */
|
|
25
|
+
export interface LogEntry {
|
|
26
|
+
/** Epoch milliseconds, not a `Date`: `Object.freeze` does not protect a
|
|
27
|
+
* Date's internal slots, so a destination could `setTime()` the entry its
|
|
28
|
+
* siblings are about to receive. A number is immutable by construction and
|
|
29
|
+
* crosses the native bridge unchanged. */
|
|
30
|
+
readonly timestamp: number;
|
|
31
|
+
readonly level: LogLevel;
|
|
32
|
+
readonly message: string;
|
|
33
|
+
readonly metadata?: RedactedMetadata;
|
|
34
|
+
readonly correlation?: string;
|
|
35
|
+
readonly subsystem?: string;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAW,CAAC;AAE3D,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AAE1C;+DAC+D;AAC/D,MAAM,MAAM,QAAQ,GAClB,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9D;;iDAEiD;AACjD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;AAElD,qDAAqD;AACrD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAErD;gEACgE;AAChE,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,CAAC;AAEjE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEnD;;gEAEgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAEtE;;;;cAIc;AACd,MAAM,WAAW,QAAQ;IACvB;;;8CAG0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UTF-8 byte length, without allocating an encoder.
|
|
3
|
+
*
|
|
4
|
+
* `TextEncoder` is not guaranteed on every Hermes build this package targets,
|
|
5
|
+
* and counting is cheaper than encoding when the answer is all that is
|
|
6
|
+
* wanted. Every byte budget in this package — the sink's payload cap, the
|
|
7
|
+
* batcher's pending cap, a formatter's truncation limit — is a UTF-8 budget,
|
|
8
|
+
* because that is what actually reaches the file.
|
|
9
|
+
*
|
|
10
|
+
* An unpaired surrogate counts as 3, matching every standard encoder: it has
|
|
11
|
+
* no UTF-8 form of its own, so encoders substitute U+FFFD, which is three
|
|
12
|
+
* bytes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function utf8Length(text: string): number;
|
|
15
|
+
//# sourceMappingURL=utf8.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8.d.ts","sourceRoot":"","sources":["../../../src/utf8.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAyB/C"}
|
package/nitro.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cxxNamespace": ["nitrologger"],
|
|
3
|
+
"ios": {
|
|
4
|
+
"iosModuleName": "NitroLogger"
|
|
5
|
+
},
|
|
6
|
+
"android": {
|
|
7
|
+
"androidNamespace": ["nitrologger"],
|
|
8
|
+
"androidCxxLibName": "nitrologger"
|
|
9
|
+
},
|
|
10
|
+
"autolinking": {
|
|
11
|
+
"FileSink": {
|
|
12
|
+
"ios": {
|
|
13
|
+
"language": "swift",
|
|
14
|
+
"implementationClassName": "HybridFileSink"
|
|
15
|
+
},
|
|
16
|
+
"android": {
|
|
17
|
+
"language": "kotlin",
|
|
18
|
+
"implementationClassName": "HybridFileSink"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"NativeConsoleSink": {
|
|
22
|
+
"ios": {
|
|
23
|
+
"language": "swift",
|
|
24
|
+
"implementationClassName": "HybridNativeConsoleSink"
|
|
25
|
+
},
|
|
26
|
+
"android": {
|
|
27
|
+
"language": "kotlin",
|
|
28
|
+
"implementationClassName": "HybridNativeConsoleSink"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"ignorePaths": ["node_modules"]
|
|
33
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JAppendResult.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "AppendResult.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JRejectReason.hpp"
|
|
14
|
+
#include "RejectReason.hpp"
|
|
15
|
+
#include <optional>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitrologger {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The C++ JNI bridge between the C++ struct "AppendResult" and the Kotlin data class "AppendResult".
|
|
23
|
+
*/
|
|
24
|
+
struct JAppendResult final: public jni::JavaClass<JAppendResult> {
|
|
25
|
+
public:
|
|
26
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrologger/AppendResult;";
|
|
27
|
+
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Convert this Java/Kotlin-based struct to the C++ struct AppendResult by copying all values to C++.
|
|
31
|
+
*/
|
|
32
|
+
[[maybe_unused]]
|
|
33
|
+
[[nodiscard]]
|
|
34
|
+
AppendResult toCpp() const {
|
|
35
|
+
static const auto clazz = javaClassStatic();
|
|
36
|
+
static const auto fieldAccepted = clazz->getField<jboolean>("accepted");
|
|
37
|
+
jboolean accepted = this->getFieldValue(fieldAccepted);
|
|
38
|
+
static const auto fieldRejectReason = clazz->getField<JRejectReason>("rejectReason");
|
|
39
|
+
jni::local_ref<JRejectReason> rejectReason = this->getFieldValue(fieldRejectReason);
|
|
40
|
+
static const auto fieldQueuedBytes = clazz->getField<double>("queuedBytes");
|
|
41
|
+
double queuedBytes = this->getFieldValue(fieldQueuedBytes);
|
|
42
|
+
static const auto fieldLostBytes = clazz->getField<double>("lostBytes");
|
|
43
|
+
double lostBytes = this->getFieldValue(fieldLostBytes);
|
|
44
|
+
static const auto fieldLostEntries = clazz->getField<double>("lostEntries");
|
|
45
|
+
double lostEntries = this->getFieldValue(fieldLostEntries);
|
|
46
|
+
static const auto fieldDegraded = clazz->getField<double>("degraded");
|
|
47
|
+
double degraded = this->getFieldValue(fieldDegraded);
|
|
48
|
+
return AppendResult(
|
|
49
|
+
static_cast<bool>(accepted),
|
|
50
|
+
rejectReason != nullptr ? std::make_optional(rejectReason->toCpp()) : std::nullopt,
|
|
51
|
+
queuedBytes,
|
|
52
|
+
lostBytes,
|
|
53
|
+
lostEntries,
|
|
54
|
+
degraded
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
/**
|
|
60
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
61
|
+
*/
|
|
62
|
+
[[maybe_unused]]
|
|
63
|
+
static jni::local_ref<JAppendResult::javaobject> fromCpp(const AppendResult& value) {
|
|
64
|
+
using JSignature = JAppendResult(jboolean, jni::alias_ref<JRejectReason>, double, double, double, double);
|
|
65
|
+
static const auto clazz = javaClassStatic();
|
|
66
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
67
|
+
return create(
|
|
68
|
+
clazz,
|
|
69
|
+
value.accepted,
|
|
70
|
+
value.rejectReason.has_value() ? JRejectReason::fromCpp(value.rejectReason.value()) : nullptr,
|
|
71
|
+
value.queuedBytes,
|
|
72
|
+
value.lostBytes,
|
|
73
|
+
value.lostEntries,
|
|
74
|
+
value.degraded
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro::nitrologger
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JClearOutcome.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "ClearOutcome.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <vector>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::nitrologger {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "ClearOutcome" and the Kotlin data class "ClearOutcome".
|
|
22
|
+
*/
|
|
23
|
+
struct JClearOutcome final: public jni::JavaClass<JClearOutcome> {
|
|
24
|
+
public:
|
|
25
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrologger/ClearOutcome;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ClearOutcome by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
ClearOutcome toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldDeletedCount = clazz->getField<double>("deletedCount");
|
|
36
|
+
double deletedCount = this->getFieldValue(fieldDeletedCount);
|
|
37
|
+
static const auto fieldFailedPaths = clazz->getField<jni::JArrayClass<jni::JString>>("failedPaths");
|
|
38
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> failedPaths = this->getFieldValue(fieldFailedPaths);
|
|
39
|
+
static const auto fieldDurable = clazz->getField<jboolean>("durable");
|
|
40
|
+
jboolean durable = this->getFieldValue(fieldDurable);
|
|
41
|
+
static const auto fieldRebound = clazz->getField<jboolean>("rebound");
|
|
42
|
+
jboolean rebound = this->getFieldValue(fieldRebound);
|
|
43
|
+
return ClearOutcome(
|
|
44
|
+
deletedCount,
|
|
45
|
+
[&](auto&& __input) {
|
|
46
|
+
size_t __size = __input->size();
|
|
47
|
+
std::vector<std::string> __vector;
|
|
48
|
+
__vector.reserve(__size);
|
|
49
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
50
|
+
auto __element = __input->getElement(__i);
|
|
51
|
+
__vector.push_back(__element->toStdString());
|
|
52
|
+
}
|
|
53
|
+
return __vector;
|
|
54
|
+
}(failedPaths),
|
|
55
|
+
static_cast<bool>(durable),
|
|
56
|
+
static_cast<bool>(rebound)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
/**
|
|
62
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
63
|
+
*/
|
|
64
|
+
[[maybe_unused]]
|
|
65
|
+
static jni::local_ref<JClearOutcome::javaobject> fromCpp(const ClearOutcome& value) {
|
|
66
|
+
using JSignature = JClearOutcome(double, jni::alias_ref<jni::JArrayClass<jni::JString>>, jboolean, jboolean);
|
|
67
|
+
static const auto clazz = javaClassStatic();
|
|
68
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
69
|
+
return create(
|
|
70
|
+
clazz,
|
|
71
|
+
value.deletedCount,
|
|
72
|
+
[&](auto&& __input) {
|
|
73
|
+
size_t __size = __input.size();
|
|
74
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
75
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
76
|
+
const auto& __element = __input[__i];
|
|
77
|
+
auto __elementJni = jni::make_jstring(__element);
|
|
78
|
+
__array->setElement(__i, *__elementJni);
|
|
79
|
+
}
|
|
80
|
+
return __array;
|
|
81
|
+
}(value.failedPaths),
|
|
82
|
+
value.durable,
|
|
83
|
+
value.rebound
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro::nitrologger
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JFlushOutcome.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "FlushOutcome.hpp"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitrologger {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "FlushOutcome" and the Kotlin data class "FlushOutcome".
|
|
21
|
+
*/
|
|
22
|
+
struct JFlushOutcome final: public jni::JavaClass<JFlushOutcome> {
|
|
23
|
+
public:
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrologger/FlushOutcome;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct FlushOutcome by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
FlushOutcome toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldDurable = clazz->getField<jboolean>("durable");
|
|
35
|
+
jboolean durable = this->getFieldValue(fieldDurable);
|
|
36
|
+
static const auto fieldTimedOut = clazz->getField<jboolean>("timedOut");
|
|
37
|
+
jboolean timedOut = this->getFieldValue(fieldTimedOut);
|
|
38
|
+
static const auto fieldPendingBytes = clazz->getField<double>("pendingBytes");
|
|
39
|
+
double pendingBytes = this->getFieldValue(fieldPendingBytes);
|
|
40
|
+
static const auto fieldQueuedBytes = clazz->getField<double>("queuedBytes");
|
|
41
|
+
double queuedBytes = this->getFieldValue(fieldQueuedBytes);
|
|
42
|
+
static const auto fieldLostBytes = clazz->getField<double>("lostBytes");
|
|
43
|
+
double lostBytes = this->getFieldValue(fieldLostBytes);
|
|
44
|
+
static const auto fieldLostEntries = clazz->getField<double>("lostEntries");
|
|
45
|
+
double lostEntries = this->getFieldValue(fieldLostEntries);
|
|
46
|
+
static const auto fieldDegraded = clazz->getField<double>("degraded");
|
|
47
|
+
double degraded = this->getFieldValue(fieldDegraded);
|
|
48
|
+
return FlushOutcome(
|
|
49
|
+
static_cast<bool>(durable),
|
|
50
|
+
static_cast<bool>(timedOut),
|
|
51
|
+
pendingBytes,
|
|
52
|
+
queuedBytes,
|
|
53
|
+
lostBytes,
|
|
54
|
+
lostEntries,
|
|
55
|
+
degraded
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
/**
|
|
61
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
62
|
+
*/
|
|
63
|
+
[[maybe_unused]]
|
|
64
|
+
static jni::local_ref<JFlushOutcome::javaobject> fromCpp(const FlushOutcome& value) {
|
|
65
|
+
using JSignature = JFlushOutcome(jboolean, jboolean, double, double, double, double, double);
|
|
66
|
+
static const auto clazz = javaClassStatic();
|
|
67
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
68
|
+
return create(
|
|
69
|
+
clazz,
|
|
70
|
+
value.durable,
|
|
71
|
+
value.timedOut,
|
|
72
|
+
value.pendingBytes,
|
|
73
|
+
value.queuedBytes,
|
|
74
|
+
value.lostBytes,
|
|
75
|
+
value.lostEntries,
|
|
76
|
+
value.degraded
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
} // namespace margelo::nitro::nitrologger
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridFileSinkSpec.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 "JHybridFileSinkSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `AppendResult` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::nitrologger { struct AppendResult; }
|
|
12
|
+
// Forward declaration of `RejectReason` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::nitrologger { enum class RejectReason; }
|
|
14
|
+
// Forward declaration of `SinkStatus` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::nitrologger { struct SinkStatus; }
|
|
16
|
+
// Forward declaration of `FlushOutcome` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrologger { struct FlushOutcome; }
|
|
18
|
+
// Forward declaration of `ClearOutcome` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitrologger { struct ClearOutcome; }
|
|
20
|
+
// Forward declaration of `RotationConfig` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::nitrologger { struct RotationConfig; }
|
|
22
|
+
|
|
23
|
+
#include <string>
|
|
24
|
+
#include "AppendResult.hpp"
|
|
25
|
+
#include "JAppendResult.hpp"
|
|
26
|
+
#include "RejectReason.hpp"
|
|
27
|
+
#include <optional>
|
|
28
|
+
#include "JRejectReason.hpp"
|
|
29
|
+
#include "SinkStatus.hpp"
|
|
30
|
+
#include "JSinkStatus.hpp"
|
|
31
|
+
#include "FlushOutcome.hpp"
|
|
32
|
+
#include "JFlushOutcome.hpp"
|
|
33
|
+
#include <vector>
|
|
34
|
+
#include "ClearOutcome.hpp"
|
|
35
|
+
#include "JClearOutcome.hpp"
|
|
36
|
+
#include "RotationConfig.hpp"
|
|
37
|
+
#include "JRotationConfig.hpp"
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro::nitrologger {
|
|
40
|
+
|
|
41
|
+
std::shared_ptr<JHybridFileSinkSpec> JHybridFileSinkSpec::JavaPart::getJHybridFileSinkSpec() {
|
|
42
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
43
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridFileSinkSpec>(hybridObject);
|
|
44
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
45
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridFileSinkSpec!");
|
|
46
|
+
}
|
|
47
|
+
return castHybridObject;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
jni::local_ref<JHybridFileSinkSpec::CxxPart::jhybriddata> JHybridFileSinkSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
51
|
+
return makeCxxInstance(jThis);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
std::shared_ptr<JHybridObject> JHybridFileSinkSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
55
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridFileSinkSpec::JavaPart>(javaPart);
|
|
56
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
57
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridFileSinkSpec::JavaPart!");
|
|
58
|
+
}
|
|
59
|
+
return std::make_shared<JHybridFileSinkSpec>(castJavaPart);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void JHybridFileSinkSpec::CxxPart::registerNatives() {
|
|
63
|
+
registerHybrid({
|
|
64
|
+
makeNativeMethod("initHybrid", JHybridFileSinkSpec::CxxPart::initHybrid),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Properties
|
|
69
|
+
std::string JHybridFileSinkSpec::getDefaultLogDirectory() {
|
|
70
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getDefaultLogDirectory");
|
|
71
|
+
auto __result = method(_javaPart);
|
|
72
|
+
return __result->toStdString();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Methods
|
|
76
|
+
void JHybridFileSinkSpec::open(const std::string& path, const std::optional<RotationConfig>& rotation, std::optional<bool> lineFramed) {
|
|
77
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* path */, jni::alias_ref<JRotationConfig> /* rotation */, jni::alias_ref<jni::JBoolean> /* lineFramed */)>("open");
|
|
78
|
+
method(_javaPart, jni::make_jstring(path), rotation.has_value() ? JRotationConfig::fromCpp(rotation.value()) : nullptr, lineFramed.has_value() ? jni::JBoolean::valueOf(lineFramed.value()) : nullptr);
|
|
79
|
+
}
|
|
80
|
+
AppendResult JHybridFileSinkSpec::appendBatch(const std::string& batch, double entryCount) {
|
|
81
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JAppendResult>(jni::alias_ref<jni::JString> /* batch */, double /* entryCount */)>("appendBatch");
|
|
82
|
+
auto __result = method(_javaPart, jni::make_jstring(batch), entryCount);
|
|
83
|
+
return __result->toCpp();
|
|
84
|
+
}
|
|
85
|
+
SinkStatus JHybridFileSinkSpec::getStatus() {
|
|
86
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSinkStatus>()>("getStatus");
|
|
87
|
+
auto __result = method(_javaPart);
|
|
88
|
+
return __result->toCpp();
|
|
89
|
+
}
|
|
90
|
+
FlushOutcome JHybridFileSinkSpec::flush(double deadlineMs) {
|
|
91
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFlushOutcome>(double /* deadlineMs */)>("flush");
|
|
92
|
+
auto __result = method(_javaPart, deadlineMs);
|
|
93
|
+
return __result->toCpp();
|
|
94
|
+
}
|
|
95
|
+
FlushOutcome JHybridFileSinkSpec::close(double deadlineMs) {
|
|
96
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFlushOutcome>(double /* deadlineMs */)>("close");
|
|
97
|
+
auto __result = method(_javaPart, deadlineMs);
|
|
98
|
+
return __result->toCpp();
|
|
99
|
+
}
|
|
100
|
+
std::vector<std::string> JHybridFileSinkSpec::getLogFilePaths() {
|
|
101
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<jni::JString>>()>("getLogFilePaths");
|
|
102
|
+
auto __result = method(_javaPart);
|
|
103
|
+
return [&](auto&& __input) {
|
|
104
|
+
size_t __size = __input->size();
|
|
105
|
+
std::vector<std::string> __vector;
|
|
106
|
+
__vector.reserve(__size);
|
|
107
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
108
|
+
auto __element = __input->getElement(__i);
|
|
109
|
+
__vector.push_back(__element->toStdString());
|
|
110
|
+
}
|
|
111
|
+
return __vector;
|
|
112
|
+
}(__result);
|
|
113
|
+
}
|
|
114
|
+
ClearOutcome JHybridFileSinkSpec::clearLogs(double deadlineMs) {
|
|
115
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JClearOutcome>(double /* deadlineMs */)>("clearLogs");
|
|
116
|
+
auto __result = method(_javaPart, deadlineMs);
|
|
117
|
+
return __result->toCpp();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
} // namespace margelo::nitro::nitrologger
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridFileSinkSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitrologger {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridFileSinkSpec: public virtual HybridFileSinkSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrologger/HybridFileSinkSpec;";
|
|
25
|
+
std::shared_ptr<JHybridFileSinkSpec> getJHybridFileSinkSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrologger/HybridFileSinkSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
explicit JHybridFileSinkSpec(const jni::local_ref<JHybridFileSinkSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridFileSinkSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridFileSinkSpec() override {
|
|
42
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridFileSinkSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
std::string getDefaultLogDirectory() override;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
void open(const std::string& path, const std::optional<RotationConfig>& rotation, std::optional<bool> lineFramed) override;
|
|
58
|
+
AppendResult appendBatch(const std::string& batch, double entryCount) override;
|
|
59
|
+
SinkStatus getStatus() override;
|
|
60
|
+
FlushOutcome flush(double deadlineMs) override;
|
|
61
|
+
FlushOutcome close(double deadlineMs) override;
|
|
62
|
+
std::vector<std::string> getLogFilePaths() override;
|
|
63
|
+
ClearOutcome clearLogs(double deadlineMs) override;
|
|
64
|
+
|
|
65
|
+
private:
|
|
66
|
+
jni::global_ref<JHybridFileSinkSpec::JavaPart> _javaPart;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
} // namespace margelo::nitro::nitrologger
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNativeConsoleSinkSpec.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 "JHybridNativeConsoleSinkSpec.hpp"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <vector>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitrologger {
|
|
16
|
+
|
|
17
|
+
std::shared_ptr<JHybridNativeConsoleSinkSpec> JHybridNativeConsoleSinkSpec::JavaPart::getJHybridNativeConsoleSinkSpec() {
|
|
18
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
19
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridNativeConsoleSinkSpec>(hybridObject);
|
|
20
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
21
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridNativeConsoleSinkSpec!");
|
|
22
|
+
}
|
|
23
|
+
return castHybridObject;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
jni::local_ref<JHybridNativeConsoleSinkSpec::CxxPart::jhybriddata> JHybridNativeConsoleSinkSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
27
|
+
return makeCxxInstance(jThis);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
std::shared_ptr<JHybridObject> JHybridNativeConsoleSinkSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
31
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridNativeConsoleSinkSpec::JavaPart>(javaPart);
|
|
32
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
33
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridNativeConsoleSinkSpec::JavaPart!");
|
|
34
|
+
}
|
|
35
|
+
return std::make_shared<JHybridNativeConsoleSinkSpec>(castJavaPart);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void JHybridNativeConsoleSinkSpec::CxxPart::registerNatives() {
|
|
39
|
+
registerHybrid({
|
|
40
|
+
makeNativeMethod("initHybrid", JHybridNativeConsoleSinkSpec::CxxPart::initHybrid),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Properties
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// Methods
|
|
48
|
+
void JHybridNativeConsoleSinkSpec::install(const std::string& subsystem, const std::string& category) {
|
|
49
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* subsystem */, jni::alias_ref<jni::JString> /* category */)>("install");
|
|
50
|
+
method(_javaPart, jni::make_jstring(subsystem), jni::make_jstring(category));
|
|
51
|
+
}
|
|
52
|
+
void JHybridNativeConsoleSinkSpec::logBatch(const std::vector<double>& levels, const std::vector<std::string>& messages) {
|
|
53
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayDouble> /* levels */, jni::alias_ref<jni::JArrayClass<jni::JString>> /* messages */)>("logBatch");
|
|
54
|
+
method(_javaPart, [&]() {
|
|
55
|
+
size_t __size = levels.size();
|
|
56
|
+
jni::local_ref<jni::JArrayDouble> __array = jni::JArrayDouble::newArray(__size);
|
|
57
|
+
__array->setRegion(0, __size, levels.data());
|
|
58
|
+
return __array;
|
|
59
|
+
}(), [&](auto&& __input) {
|
|
60
|
+
size_t __size = __input.size();
|
|
61
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
62
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
63
|
+
const auto& __element = __input[__i];
|
|
64
|
+
auto __elementJni = jni::make_jstring(__element);
|
|
65
|
+
__array->setElement(__i, *__elementJni);
|
|
66
|
+
}
|
|
67
|
+
return __array;
|
|
68
|
+
}(messages));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::nitrologger
|