@unvired/react-native-unvired-sdk 0.0.10 → 0.0.11

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/BuildNo.txt CHANGED
@@ -1 +1 @@
1
- R-0.000.0010
1
+ R-0.000.0011
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { Logger, logger } from './logger/Logger';
2
- export type { LogLevel, ILogger, ILoggerImplementation, ILoggerConfig, ILogEntry, ILogFileInfo } from './logger/Logger';
2
+ export type { LogLevel, ILogger, ILoggerImplementation, } from './logger/Logger';
3
3
  export { default } from './logger/Logger';
@@ -16,13 +16,4 @@ export declare class BaseLogger {
16
16
  getLogFileContent(): Promise<string>;
17
17
  getBackupLogFileContent(): Promise<string | null>;
18
18
  clearLogFile(): Promise<void>;
19
- get logFile(): string;
20
- write(message: string): Promise<void>;
21
- readLog(): Promise<string>;
22
- rotateLog(): Promise<void>;
23
- getLogSizes(): Promise<{
24
- logFile: number;
25
- backupFile: number;
26
- }>;
27
- private getFileSize;
28
19
  }
@@ -2,7 +2,7 @@
2
2
  import { Platform } from 'react-native';
3
3
  import { LoggerNative } from './services/LoggerNative';
4
4
  import { LoggerWeb } from './services/LoggerWeb';
5
- export const MAX_LOG_SIZE = 1 * 1024 * 1024;
5
+ export const MAX_LOG_SIZE = 100 * 1024 * 1024;
6
6
  export class BaseLogger {
7
7
  constructor() {
8
8
  this.logLevel = 'info';
@@ -72,47 +72,4 @@ export class BaseLogger {
72
72
  getLogFileContent() { return this.impl.getLogFileContent(); }
73
73
  getBackupLogFileContent() { return this.impl.getBackupLogFileContent(); }
74
74
  clearLogFile() { return this.impl.clear(); }
75
- // -------------------------
76
- // ILogger interface compatibility
77
- // -------------------------
78
- get logFile() {
79
- return this.impl.logFile || '';
80
- }
81
- async write(message) {
82
- const line = `[${new Date().toISOString()}] ${message}`;
83
- await this.impl.writeLine(line, MAX_LOG_SIZE);
84
- }
85
- async readLog() {
86
- return this.impl.getLogFileContent();
87
- }
88
- async rotateLog() {
89
- if (this.impl.rotateLog) {
90
- await this.impl.rotateLog();
91
- }
92
- else {
93
- // For Windows, force rotation by writing max size
94
- await this.impl.writeLine('', Number.MAX_SAFE_INTEGER);
95
- }
96
- }
97
- async getLogSizes() {
98
- const logSize = await this.getFileSize(this.impl.logFile);
99
- const backupSize = await this.getFileSize(this.impl.backupZip || this.impl.tempFile || '');
100
- return { logFile: logSize, backupFile: backupSize };
101
- }
102
- async getFileSize(path) {
103
- if (!path)
104
- return 0;
105
- try {
106
- // Try to use RNFS if available
107
- const RNFS = require('@dr.pogodin/react-native-fs');
108
- if (await RNFS.exists(path)) {
109
- const stat = await RNFS.stat(path);
110
- return stat.size;
111
- }
112
- }
113
- catch {
114
- // Ignore
115
- }
116
- return 0;
117
- }
118
75
  }
@@ -2,6 +2,6 @@ import { BaseLogger, LogLevel } from './BaseLogger';
2
2
  export declare class Logger extends BaseLogger {
3
3
  }
4
4
  export declare const logger: Logger;
5
- export type { ILogger, ILoggerImplementation, ILoggerConfig, ILogEntry, ILogFileInfo, } from './Logger.types';
5
+ export type { ILogger, ILoggerImplementation, } from './Logger.types';
6
6
  export type { LogLevel };
7
7
  export default logger;
@@ -13,7 +13,6 @@ export interface ILoggerImplementation {
13
13
  backupZip?: string;
14
14
  init(): Promise<void>;
15
15
  writeLine(line: string, maxSize: number): Promise<void>;
16
- rotateLog?(): Promise<void>;
17
16
  getLogFileURL(): Promise<string>;
18
17
  getLogFileContent(): Promise<string>;
19
18
  getBackupLogFileContent(): Promise<string | null>;
@@ -24,48 +23,12 @@ export interface ILoggerImplementation {
24
23
  * This is what consumers of the logger package should use
25
24
  */
26
25
  export interface ILogger {
27
- logFile: string;
28
- setLogLevel?(level: LogLevel): void;
29
- logDebug?(className: string, methodName: string, message: string): void;
30
- logInfo?(className: string, methodName: string, message: string): void;
31
- logError?(className: string, methodName: string, message: string): void;
32
- write(message: string): Promise<void>;
33
- readLog(): Promise<string>;
34
- rotateLog(): Promise<void>;
35
- getLogSizes(): Promise<{
36
- logFile: number;
37
- backupFile: number;
38
- }>;
39
- getLogFileURL?(): Promise<string>;
40
- getLogFileContent?(): Promise<string>;
26
+ setLogLevel(level: LogLevel): void;
27
+ logDebug(className: string, methodName: string, message: string): void;
28
+ logInfo(className: string, methodName: string, message: string): void;
29
+ logError(className: string, methodName: string, message: string): void;
30
+ getLogFileURL(): Promise<string>;
31
+ getLogFileContent(): Promise<string>;
41
32
  getBackupLogFileContent(): Promise<string | null>;
42
- clearLogFile?(): Promise<void>;
43
- }
44
- /**
45
- * Configuration options for logger initialization
46
- */
47
- export interface ILoggerConfig {
48
- logLevel?: LogLevel;
49
- maxLogSize?: number;
50
- logDir?: string;
51
- logFileName?: string;
52
- }
53
- /**
54
- * Log entry structure
55
- */
56
- export interface ILogEntry {
57
- timestamp: string;
58
- level: LogLevel;
59
- className?: string;
60
- methodName?: string;
61
- message: string;
62
- }
63
- /**
64
- * Log file information
65
- */
66
- export interface ILogFileInfo {
67
- path: string;
68
- size: number;
69
- exists: boolean;
70
- lastModified?: Date;
33
+ clearLogFile(): Promise<void>;
71
34
  }
@@ -9,9 +9,9 @@ export declare class LoggerNative implements ILoggerImplementation {
9
9
  init(): Promise<void>;
10
10
  writeLine(line: string, maxSize: number): Promise<void>;
11
11
  private ensureDir;
12
- rotateLog(): Promise<void>;
12
+ private rotateLog;
13
13
  getLogFileURL(): Promise<string>;
14
14
  getLogFileContent(): Promise<any>;
15
- getBackupLogFileContent(): Promise<string | null>;
15
+ getBackupLogFileContent(): Promise<any>;
16
16
  clear(): Promise<void>;
17
17
  }
@@ -28,7 +28,7 @@ export class LoggerNative {
28
28
  this.isRotating = false; // Rotation lock to prevent concurrent rotations
29
29
  this.isAvailable = false;
30
30
  const dir = 'unvired_logs_local';
31
- const file = 'applog.txt'; // main log file
31
+ const file = 'applog_local.txt'; // main log file
32
32
  if (!RNFS) {
33
33
  console.warn('⚠️ LoggerNative: RNFS not available, logging to file system disabled');
34
34
  this.logDir = '';
@@ -47,7 +47,7 @@ export class LoggerNative {
47
47
  this.logDir = '';
48
48
  }
49
49
  this.logFile = `${this.logDir}/${file}`;
50
- this.backupZip = `${this.logDir}/backuplog.zip`;
50
+ this.backupZip = `${this.logDir}/backuplog_local.zip`;
51
51
  }
52
52
  async init() {
53
53
  if (!this.isAvailable || !this.logDir || !RNFS)
@@ -174,7 +174,10 @@ export class LoggerNative {
174
174
  if (!this.isAvailable || !RNFS)
175
175
  return '';
176
176
  try {
177
- return (await RNFS.exists(this.logFile)) ? RNFS.readFile(this.logFile, 'utf8') : '';
177
+ if (await RNFS.exists(this.logFile)) {
178
+ return await RNFS.readFile(this.logFile, 'utf8');
179
+ }
180
+ return '';
178
181
  }
179
182
  catch (e) {
180
183
  console.error('❌ LoggerNative getLogFileContent error:', e);
@@ -185,9 +188,11 @@ export class LoggerNative {
185
188
  if (!this.isAvailable || !RNFS)
186
189
  return null;
187
190
  try {
191
+ // Force rotation to ensure current logs are zipped
192
+ await this.rotateLog();
188
193
  if (await RNFS.exists(this.backupZip)) {
189
- const stat = await RNFS.stat(this.backupZip);
190
- return `${stat.size}`;
194
+ // Return base64 content for download/upload
195
+ return await RNFS.readFile(this.backupZip, 'base64');
191
196
  }
192
197
  return null;
193
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unvired/react-native-unvired-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Unvired SDK for React Native with logging, database, notifications, and file system support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",