Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log error additionally #524

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading