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,14 +1,12 @@
|
||||
// @flow
|
||||
import fs from "fs";
|
||||
import debug from "debug";
|
||||
import Logger from "../../logging/logger";
|
||||
import mailer from "../../mailer";
|
||||
import { FileOperation, Collection, Event, Team, User } from "../../models";
|
||||
import type { Event as TEvent } from "../../types";
|
||||
import { uploadToS3FromBuffer } from "../../utils/s3";
|
||||
import { archiveCollections } from "../../utils/zip";
|
||||
|
||||
const log = debug("commands");
|
||||
|
||||
export default class ExportsProcessor {
|
||||
async on(event: TEvent) {
|
||||
switch (event.name) {
|
||||
@ -30,7 +28,10 @@ export default class ExportsProcessor {
|
||||
});
|
||||
|
||||
// heavy lifting of creating the zip file
|
||||
log(`Archiving collections for file operation ${exportData.id}`);
|
||||
Logger.info(
|
||||
"processor",
|
||||
`Archiving collections for file operation ${exportData.id}`
|
||||
);
|
||||
const filePath = await archiveCollections(collections);
|
||||
|
||||
let url, state;
|
||||
@ -43,7 +44,10 @@ export default class ExportsProcessor {
|
||||
size: stat.size,
|
||||
});
|
||||
|
||||
log(`Uploading archive for file operation ${exportData.id}`);
|
||||
Logger.info(
|
||||
"processor",
|
||||
`Uploading archive for file operation ${exportData.id}`
|
||||
);
|
||||
url = await uploadToS3FromBuffer(
|
||||
readBuffer,
|
||||
"application/zip",
|
||||
@ -51,10 +55,15 @@ export default class ExportsProcessor {
|
||||
"private"
|
||||
);
|
||||
|
||||
log(`Upload complete for file operation ${exportData.id}`);
|
||||
Logger.info(
|
||||
"processor",
|
||||
`Upload complete for file operation ${exportData.id}`
|
||||
);
|
||||
state = "complete";
|
||||
} catch (e) {
|
||||
log("Failed to export data", e);
|
||||
} catch (error) {
|
||||
Logger.error("Error exporting collection data", error, {
|
||||
fileOperationId: exportData.id,
|
||||
});
|
||||
state = "error";
|
||||
url = null;
|
||||
} finally {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// @flow
|
||||
import debug from "debug";
|
||||
import Logger from "../../logging/logger";
|
||||
import mailer from "../../mailer";
|
||||
import {
|
||||
View,
|
||||
@ -12,8 +12,6 @@ import {
|
||||
import { Op } from "../../sequelize";
|
||||
import type { DocumentEvent, CollectionEvent, Event } from "../../types";
|
||||
|
||||
const log = debug("services");
|
||||
|
||||
export default class NotificationsProcessor {
|
||||
async on(event: Event) {
|
||||
switch (event.name) {
|
||||
@ -98,7 +96,8 @@ export default class NotificationsProcessor {
|
||||
});
|
||||
|
||||
if (view) {
|
||||
log(
|
||||
Logger.info(
|
||||
"processor",
|
||||
`suppressing notification to ${setting.userId} because update viewed`
|
||||
);
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user