@peers-app/peers-sdk 0.7.22 → 0.7.23

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.
@@ -4,6 +4,8 @@ exports.Logger = void 0;
4
4
  exports.setupConsoleLogsProxy = setupConsoleLogsProxy;
5
5
  exports.restoreConsole = restoreConsole;
6
6
  exports.extractCoreMessage = extractCoreMessage;
7
+ const lodash_1 = require("lodash");
8
+ const serial_json_1 = require("../serial-json");
7
9
  const utils_1 = require("../utils");
8
10
  const console_logs_table_1 = require("./console-logs.table");
9
11
  // Store original console methods
@@ -152,43 +154,6 @@ function checkLogSignature(signature) {
152
154
  }
153
155
  return true;
154
156
  }
155
- /**
156
- * Format log arguments into a single message string
157
- */
158
- function formatLogMessage(args) {
159
- return args.map((arg) => {
160
- if (typeof arg === 'string') {
161
- return arg;
162
- }
163
- if (arg instanceof Error) {
164
- return `${arg.name}: ${arg.message}`;
165
- }
166
- if (typeof arg === 'object') {
167
- try {
168
- return JSON.stringify(arg);
169
- }
170
- catch {
171
- return String(arg);
172
- }
173
- }
174
- return String(arg);
175
- }).join(' ');
176
- }
177
- /**
178
- * Extract structured context objects from log arguments
179
- */
180
- function extractContext(args) {
181
- if (args.length === 0) {
182
- return undefined;
183
- }
184
- if (args.length === 1) {
185
- const singleArg = args[0];
186
- if (typeof singleArg !== 'object') {
187
- return { value: singleArg };
188
- }
189
- }
190
- return args;
191
- }
192
157
  /**
193
158
  * Get current stack trace
194
159
  */
@@ -240,7 +205,9 @@ async function writeLogToDatabaseWithSource(level, source, args) {
240
205
  try {
241
206
  const timestamp = (0, utils_1.getTimestamp)();
242
207
  // Format message from arguments
243
- const message = formatLogMessage(args);
208
+ let message = typeof args[0] === 'string' ?
209
+ args.shift() :
210
+ (0, serial_json_1.toJSONString)(args[0]);
244
211
  // Check for infinite loop before writing
245
212
  // Extract core message to detect cross-process loops where prefixes are added
246
213
  const coreMessage = extractCoreMessage(message);
@@ -250,7 +217,16 @@ async function writeLogToDatabaseWithSource(level, source, args) {
250
217
  return;
251
218
  }
252
219
  // Extract context objects from arguments
253
- const context = extractContext(args);
220
+ for (const a of [...args]) {
221
+ if (typeof a === 'object' && !((0, lodash_1.isDate)(a) || a === null)) {
222
+ break;
223
+ }
224
+ message += ' ' + args.shift();
225
+ }
226
+ let context = args.length === 0 ?
227
+ undefined : args.length === 1 ?
228
+ args[0] :
229
+ args;
254
230
  // Get stack trace for errors
255
231
  const stackTrace = level === 'error' ? getStackTrace() : undefined;
256
232
  const logRecord = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peers-app/peers-sdk",
3
- "version": "0.7.22",
3
+ "version": "0.7.23",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/peers-app/peers-sdk.git"