Skip to content

Commit

Permalink
improving error logs
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelbeltran committed May 8, 2024
1 parent 19173cd commit 11fed35
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/raygun.offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class OfflineStorage implements IOfflineStorage {
this.cacheLimit = offlineStorageOptions.cacheLimit || 100;

debug(
`offline storage - initialized (cachePath=${this.cachePath}, cacheLimit=${this.cacheLimit}`,
`[raygun.offline.ts] offline storage - initialized (cachePath=${this.cachePath}, cacheLimit=${this.cacheLimit}`,
);

if (!fs.existsSync(this.cachePath)) {
Expand All @@ -63,23 +63,23 @@ export class OfflineStorage implements IOfflineStorage {

fs.readdir(this.cachePath, (err, files) => {
if (err) {
console.log("[Raygun] Error reading cache folder");
console.log("[Raygun4Node] Error reading cache folder");
console.log(err);
return callback(err);
}

if (files.length > this.cacheLimit) {
console.log("[Raygun] Error cache reached limit");
console.log("[Raygun4Node] Error cache reached limit");
return callback(null);
}

fs.writeFile(filename, transportItem, "utf8", function (err) {
if (!err) {
debug(`offline storage - wrote message to ${filename}`);
debug(`[raygun.offline.ts] offline storage - wrote message to ${filename}`);
return callback(null);
}

console.log("[Raygun] Error writing to cache folder");
console.log("[Raygun4Node] Error writing to cache folder");
console.log(err);

return callback(err);
Expand All @@ -96,14 +96,14 @@ export class OfflineStorage implements IOfflineStorage {
send(callback: (error: Error | null, items?: string[]) => void) {
this.retrieve((err, items) => {
if (err) {
console.log("[Raygun] Error reading cache folder");
console.log("[Raygun4Node] Error reading cache folder");
console.log(err);
return callback(err);
}

if (items.length > 0) {
debug(
"offline storage - transporting ${items.length} message(s) from cache",
"[raygun.offline.ts] offline storage - transporting ${items.length} message(s) from cache",
);
}

Expand Down

0 comments on commit 11fed35

Please sign in to comment.