mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 15:30:41 +09:00
Add winston based logger for master, slave, ctl, lib, and web_ui code. Logging done from slaves and instances are sent to the master server and tagged with the instance and/or slave it originated from. This allows for example error messages to propagate back to the source that iniated the action. The master server also stores the log to allow it to be queried at a later point. For slaves a copy of the slave's log is also stored locally.
37 lines
924 B
React
37 lines
924 B
React
import { notification } from "antd";
|
|
import { logger } from "@clusterio/lib/logging";
|
|
|
|
|
|
export default function notify(message, type = "info", description = undefined) {
|
|
notification[type]({
|
|
message: typeof message === "string" ? message : "ERROR: See console",
|
|
description,
|
|
placement: "bottomRight",
|
|
});
|
|
if (typeof message !== "string") {
|
|
logger.error(message.stack);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Promise rejection handler notifying the user
|
|
*
|
|
* Shows the error occuring in a notification card.
|
|
*
|
|
* @param {string} message -
|
|
* User facing message to give context to the error. Should say which
|
|
* operation failed.
|
|
* @returns {function(err)} function showing the error passed to it.
|
|
*/
|
|
export function notifyErrorHandler(message) {
|
|
return function handler(err) {
|
|
logger.error(err.stack);
|
|
notification.error({
|
|
message,
|
|
description: err.message,
|
|
duration: 0,
|
|
placement: "bottomRight",
|
|
});
|
|
};
|
|
}
|