feat: use logger
This commit is contained in:
@@ -11,6 +11,7 @@ import remarkFrontmatter, {
|
||||
import * as cache from "@lib/cache/documents.ts";
|
||||
import { SILVERBULLET_SERVER } from "@lib/env.ts";
|
||||
import { fixRenderedMarkdown } from "@lib/helpers.ts";
|
||||
import { createLogger } from "@lib/log.ts";
|
||||
|
||||
export type Document = {
|
||||
name: string;
|
||||
@@ -20,13 +21,15 @@ export type Document = {
|
||||
perm: string;
|
||||
};
|
||||
|
||||
const log = createLogger("documents");
|
||||
|
||||
export async function getDocuments(): Promise<Document[]> {
|
||||
const cachedDocuments = await cache.getDocuments();
|
||||
if (cachedDocuments) return cachedDocuments;
|
||||
|
||||
const headers = new Headers();
|
||||
headers.append("Accept", "application/json");
|
||||
console.log("[documents] fetching all documents");
|
||||
log.debug("fetching all documents");
|
||||
const response = await fetch(`${SILVERBULLET_SERVER}/index.json`, {
|
||||
headers: headers,
|
||||
});
|
||||
@@ -48,7 +51,7 @@ export function createDocument(
|
||||
headers.append("Content-Type", mediaType);
|
||||
}
|
||||
|
||||
console.log("[documents] creating document", { name });
|
||||
log.info("creating document", { name });
|
||||
|
||||
return fetch(SILVERBULLET_SERVER + "/" + name, {
|
||||
body: content,
|
||||
@@ -61,7 +64,7 @@ export async function getDocument(name: string): Promise<string> {
|
||||
const cachedDocument = await cache.getDocument(name);
|
||||
if (cachedDocument) return cachedDocument;
|
||||
|
||||
console.log("[documents] fetching document", { name });
|
||||
log.debug("fetching document", { name });
|
||||
const response = await fetch(SILVERBULLET_SERVER + "/" + name);
|
||||
const text = await response.text();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user