refactor(logs): move to core package (#4586)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createId } from "@homarr/common";
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";
|
||||
import { logger } from "@homarr/log";
|
||||
import type { BoardSize, OldmarrConfig } from "@homarr/old-schema";
|
||||
import { boardSizes, getBoardSizeName } from "@homarr/old-schema";
|
||||
|
||||
@@ -15,6 +15,8 @@ import type { prepareMultipleImports } from "../../prepare/prepare-multiple";
|
||||
import { prepareSections } from "../../prepare/prepare-sections";
|
||||
import type { InitialOldmarrImportSettings } from "../../settings";
|
||||
|
||||
const logger = createLogger({ module: "boardCollection" });
|
||||
|
||||
export const createBoardInsertCollection = (
|
||||
{ preparedApps, preparedBoards }: Omit<ReturnType<typeof prepareMultipleImports>, "preparedIntegrations">,
|
||||
settings: InitialOldmarrImportSettings,
|
||||
@@ -50,12 +52,12 @@ export const createBoardInsertCollection = (
|
||||
}
|
||||
|
||||
if (settings.onlyImportApps) {
|
||||
logger.info(
|
||||
`Skipping boards and sections import due to onlyImportApps setting appCount=${insertCollection.apps.length}`,
|
||||
);
|
||||
logger.info("Skipping boards and sections import due to onlyImportApps setting", {
|
||||
appCount: insertCollection.apps.length,
|
||||
});
|
||||
return insertCollection;
|
||||
}
|
||||
logger.debug(`Added apps to board insert collection count=${insertCollection.apps.length}`);
|
||||
logger.debug("Added apps to board insert collection", { count: insertCollection.apps.length });
|
||||
|
||||
preparedBoards.forEach((board) => {
|
||||
if (!hasEnoughItemShapes(board.config)) {
|
||||
@@ -71,10 +73,10 @@ export const createBoardInsertCollection = (
|
||||
name: board.name,
|
||||
});
|
||||
|
||||
logger.debug(`Fixed issues with sections and item positions fileName=${board.name}`);
|
||||
logger.debug("Fixed issues with sections and item positions", { fileName: board.name });
|
||||
|
||||
const mappedBoard = mapBoard(board);
|
||||
logger.debug(`Mapped board fileName=${board.name} boardId=${mappedBoard.id}`);
|
||||
logger.debug("Mapped board", { fileName: board.name, boardId: mappedBoard.id });
|
||||
insertCollection.boards.push(mappedBoard);
|
||||
|
||||
const layoutMapping = boardSizes.reduce(
|
||||
@@ -100,7 +102,7 @@ export const createBoardInsertCollection = (
|
||||
for (const section of preparedSections.values()) {
|
||||
insertCollection.sections.push(section);
|
||||
}
|
||||
logger.debug(`Added sections to board insert collection count=${insertCollection.sections.length}`);
|
||||
logger.debug("Added sections to board insert collection", { count: insertCollection.sections.length });
|
||||
|
||||
const preparedItems = prepareItems(
|
||||
{
|
||||
@@ -117,12 +119,15 @@ export const createBoardInsertCollection = (
|
||||
insertCollection.items.push(item);
|
||||
insertCollection.itemLayouts.push(...layouts);
|
||||
});
|
||||
logger.debug(`Added items to board insert collection count=${insertCollection.items.length}`);
|
||||
logger.debug("Added items to board insert collection", { count: insertCollection.items.length });
|
||||
});
|
||||
|
||||
logger.info(
|
||||
`Board collection prepared boardCount=${insertCollection.boards.length} sectionCount=${insertCollection.sections.length} itemCount=${insertCollection.items.length} appCount=${insertCollection.apps.length}`,
|
||||
);
|
||||
logger.info("Board collection prepared", {
|
||||
boardCount: insertCollection.boards.length,
|
||||
sectionCount: insertCollection.sections.length,
|
||||
itemCount: insertCollection.items.length,
|
||||
appCount: insertCollection.apps.length,
|
||||
});
|
||||
|
||||
return insertCollection;
|
||||
};
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import { encryptSecret } from "@homarr/common/server";
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";
|
||||
import { logger } from "@homarr/log";
|
||||
|
||||
import { mapAndDecryptIntegrations } from "../../mappers/map-integration";
|
||||
import type { PreparedIntegration } from "../../prepare/prepare-integrations";
|
||||
|
||||
const logger = createLogger({ module: "integrationCollection" });
|
||||
|
||||
export const createIntegrationInsertCollection = (
|
||||
preparedIntegrations: PreparedIntegration[],
|
||||
encryptionToken: string | null | undefined,
|
||||
@@ -15,7 +17,7 @@ export const createIntegrationInsertCollection = (
|
||||
return insertCollection;
|
||||
}
|
||||
|
||||
logger.info(`Preparing integrations for insert collection count=${preparedIntegrations.length}`);
|
||||
logger.info("Preparing integrations for insert collection", { count: preparedIntegrations.length });
|
||||
|
||||
if (encryptionToken === null || encryptionToken === undefined) {
|
||||
logger.debug("Skipping integration decryption due to missing token");
|
||||
@@ -44,9 +46,10 @@ export const createIntegrationInsertCollection = (
|
||||
});
|
||||
});
|
||||
|
||||
logger.info(
|
||||
`Added integrations and secrets to insert collection integrationCount=${insertCollection.integrations.length} secretCount=${insertCollection.integrationSecrets.length}`,
|
||||
);
|
||||
logger.info("Added integrations and secrets to insert collection", {
|
||||
integrationCount: insertCollection.integrations.length,
|
||||
secretCount: insertCollection.integrationSecrets.length,
|
||||
});
|
||||
|
||||
return insertCollection;
|
||||
};
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { createId } from "@homarr/common";
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
import { createDbInsertCollectionForTransaction } from "@homarr/db/collection";
|
||||
import { credentialsAdminGroup } from "@homarr/definitions";
|
||||
import { logger } from "@homarr/log";
|
||||
|
||||
import { mapAndDecryptUsers } from "../../mappers/map-user";
|
||||
import type { OldmarrImportUser } from "../../user-schema";
|
||||
|
||||
const logger = createLogger({ module: "userCollection" });
|
||||
|
||||
export const createUserInsertCollection = (
|
||||
importUsers: OldmarrImportUser[],
|
||||
encryptionToken: string | null | undefined,
|
||||
@@ -21,7 +23,7 @@ export const createUserInsertCollection = (
|
||||
return insertCollection;
|
||||
}
|
||||
|
||||
logger.info(`Preparing users for insert collection count=${importUsers.length}`);
|
||||
logger.info("Preparing users for insert collection", { count: importUsers.length });
|
||||
|
||||
if (encryptionToken === null || encryptionToken === undefined) {
|
||||
logger.debug("Skipping user decryption due to missing token");
|
||||
@@ -30,7 +32,7 @@ export const createUserInsertCollection = (
|
||||
|
||||
const preparedUsers = mapAndDecryptUsers(importUsers, encryptionToken);
|
||||
preparedUsers.forEach((user) => insertCollection.users.push(user));
|
||||
logger.debug(`Added users to insert collection count=${insertCollection.users.length}`);
|
||||
logger.debug("Added users to insert collection", { count: insertCollection.users.length });
|
||||
|
||||
if (!preparedUsers.some((user) => user.isAdmin)) {
|
||||
logger.warn("No admin users found, skipping admin group creation");
|
||||
@@ -58,9 +60,10 @@ export const createUserInsertCollection = (
|
||||
});
|
||||
});
|
||||
|
||||
logger.info(
|
||||
`Added admin group and permissions to insert collection adminGroupId=${adminGroupId} adminUsersCount=${admins.length}`,
|
||||
);
|
||||
logger.info("Added admin group and permissions to insert collection", {
|
||||
adminGroupId,
|
||||
adminUsersCount: admins.length,
|
||||
});
|
||||
|
||||
return insertCollection;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { z } from "zod/v4";
|
||||
|
||||
import { Stopwatch } from "@homarr/common";
|
||||
import { createLogger } from "@homarr/core/infrastructure/logs";
|
||||
import { handleTransactionsAsync } from "@homarr/db";
|
||||
import type { Database } from "@homarr/db";
|
||||
import { logger } from "@homarr/log";
|
||||
|
||||
import { analyseOldmarrImportAsync } from "../analyse/analyse-oldmarr-import";
|
||||
import { prepareMultipleImports } from "../prepare/prepare-multiple";
|
||||
@@ -13,6 +13,8 @@ import { createUserInsertCollection } from "./collections/user-collection";
|
||||
import type { importInitialOldmarrInputSchema } from "./input";
|
||||
import { ensureValidTokenOrThrow } from "./validate-token";
|
||||
|
||||
const logger = createLogger({ module: "importInitialOldmarr" });
|
||||
|
||||
export const importInitialOldmarrAsync = async (
|
||||
db: Database,
|
||||
input: z.infer<typeof importInitialOldmarrInputSchema>,
|
||||
@@ -52,5 +54,5 @@ export const importInitialOldmarrAsync = async (
|
||||
},
|
||||
});
|
||||
|
||||
logger.info(`Import successful (in ${stopwatch.getElapsedInHumanWords()})`);
|
||||
logger.info("Import successful", { duration: stopwatch.getElapsedInHumanWords() });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user