2021-04-23 13:50:55 +00:00
|
|
|
import { debuggerLogInit } from "actions/debuggerActions";
|
|
|
|
|
import { Message, Severity, LogActionPayload } from "entities/AppsmithConsole";
|
|
|
|
|
import moment from "moment";
|
|
|
|
|
import store from "store";
|
2021-02-03 13:16:48 +00:00
|
|
|
|
2021-04-23 13:50:55 +00:00
|
|
|
function log(ev: Message) {
|
|
|
|
|
store.dispatch(debuggerLogInit(ev));
|
2021-02-03 13:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-23 13:50:55 +00:00
|
|
|
function getTimeStamp() {
|
|
|
|
|
return moment().format("hh:mm:ss");
|
2021-02-03 13:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-23 13:50:55 +00:00
|
|
|
function info(ev: LogActionPayload) {
|
|
|
|
|
log({
|
|
|
|
|
...ev,
|
|
|
|
|
severity: Severity.INFO,
|
|
|
|
|
timestamp: getTimeStamp(),
|
|
|
|
|
});
|
2021-02-03 13:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-23 13:50:55 +00:00
|
|
|
function warning(ev: LogActionPayload) {
|
|
|
|
|
log({
|
|
|
|
|
...ev,
|
|
|
|
|
severity: Severity.WARNING,
|
|
|
|
|
timestamp: getTimeStamp(),
|
|
|
|
|
});
|
2021-02-03 13:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-23 13:50:55 +00:00
|
|
|
function error(ev: LogActionPayload) {
|
|
|
|
|
log({
|
|
|
|
|
...ev,
|
|
|
|
|
severity: Severity.ERROR,
|
|
|
|
|
timestamp: getTimeStamp(),
|
|
|
|
|
});
|
2021-02-03 13:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
2021-04-23 13:50:55 +00:00
|
|
|
export default {
|
|
|
|
|
info,
|
|
|
|
|
warning,
|
|
|
|
|
error,
|
|
|
|
|
};
|