feat: Normalized server logging (#2567)
* feat: Normalize logging * Remove scattered console.error + Sentry.captureException * Remove mention of debug * cleanup dev output * Edge cases, docs * Refactor: Move logger, metrics, sentry under 'logging' folder. Trying to reduce the amount of things under generic 'utils' * cleanup, last few console calls
This commit is contained in:
@ -1,12 +1,11 @@
|
||||
// @flow
|
||||
import debug from "debug";
|
||||
import { debounce } from "lodash";
|
||||
import * as Y from "yjs";
|
||||
import documentUpdater from "../commands/documentUpdater";
|
||||
import Logger from "../logging/logger";
|
||||
import { Document, User } from "../models";
|
||||
import markdownToYDoc from "./utils/markdownToYDoc";
|
||||
|
||||
const log = debug("server");
|
||||
const DELAY = 3000;
|
||||
|
||||
export default class Persistence {
|
||||
@ -30,12 +29,18 @@ export default class Persistence {
|
||||
|
||||
if (document.state) {
|
||||
const ydoc = new Y.Doc();
|
||||
log(`Document ${documentId} is already in state`);
|
||||
Logger.info(
|
||||
"collaboration",
|
||||
`Document ${documentId} is in database state`
|
||||
);
|
||||
Y.applyUpdate(ydoc, document.state);
|
||||
return ydoc;
|
||||
}
|
||||
|
||||
log(`Document ${documentId} is not in state, creating state from markdown`);
|
||||
Logger.info(
|
||||
"collaboration",
|
||||
`Document ${documentId} is not in state, creating from markdown`
|
||||
);
|
||||
const ydoc = markdownToYDoc(document.text, fieldName);
|
||||
const state = Y.encodeStateAsUpdate(ydoc);
|
||||
|
||||
@ -55,7 +60,7 @@ export default class Persistence {
|
||||
}) => {
|
||||
const [, documentId] = documentName.split(".");
|
||||
|
||||
log(`persisting ${documentId}`);
|
||||
Logger.info("collaboration", `Persisting ${documentId}`);
|
||||
|
||||
await documentUpdater({
|
||||
documentId,
|
||||
|
Reference in New Issue
Block a user