Skip to content

Commit

Permalink
Merge pull request #524 from margelo/chore/log-additional-error
Browse files Browse the repository at this point in the history
chore: log error additionally
  • Loading branch information
marcaaron authored Mar 28, 2024
2 parents 905026a + b950a0e commit e2225f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type LogData = {
message: string;
level: 'alert' | 'info';
level: 'alert' | 'info' | 'hmmm';
};
type LoggerCallback = (data: LogData) => void;

Expand Down Expand Up @@ -28,4 +28,11 @@ function logInfo(message: string) {
logger({message: `[Onyx] ${message}`, level: 'info'});
}

export {registerLogger, logInfo, logAlert};
/**
* Send an hmmm message to the logger
*/
function logHmmm(message: string) {
logger({message: `[Onyx] ${message}`, level: 'hmmm'});
}

export {registerLogger, logInfo, logAlert, logHmmm};
2 changes: 1 addition & 1 deletion lib/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Storage = {
* Degrade performance by removing the storage provider and only using cache
*/
function degradePerformance(error: Error) {
Logger.logAlert(`Error while using ${provider.name}. Falling back to only using cache and dropping storage.`);
Logger.logHmmm(`Error while using ${provider.name}. Falling back to only using cache and dropping storage.\n Error: ${error.message}\n Stack: ${error.stack}\n Cause: ${error.cause}`);
console.error(error);
provider = MemoryOnlyProvider;
}
Expand Down

0 comments on commit e2225f4

Please sign in to comment.