Skip to content

Commit

Permalink
refactor: logs without formats
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Oct 2, 2024
1 parent bf98462 commit b4bf27e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 37 deletions.
6 changes: 6 additions & 0 deletions .changeset/funny-lies-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hydrofoil/talos-core": patch
"@hydrofoil/talos": patch
---

Prettier logs
24 changes: 0 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/lib/insertVocabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function insertVocab(client: StreamClient, allPrefixes: typeof prefixes) {
}`
const query = sparql`DROP SILENT GRAPH <${namespace.value}>;\n${insert}`.toString()

log('Inserting vocab %s', namespace.value)
log(`Inserting vocab ${namespace.value}`)
return client.query.update(query)
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function toGraphs(api: string) {
let previous = await previousPromise
const dataset = $rdf.dataset()

log.debug('Processing dir %s', dir)
log.debug(`Processing dir ${dir}`)

for await (const file of walk(dir)) {
if (file.endsWith('.ru')) {
Expand All @@ -70,7 +70,7 @@ function toGraphs(api: string) {
continue
}

log.debug('Parsing %s', relative)
log.debug(`Parsing ${relative}`)
const parsedResourceOptions: Partial<ResourceOptions> = { }
parserStream.on('prefix', optionsFromPrefixes(parsedResourceOptions))

Expand All @@ -81,14 +81,14 @@ function toGraphs(api: string) {
const graph: NamedNode = quad.graph.equals($rdf.defaultGraph()) ? $rdf.namedNode(url) : quad.graph

if (!resources.has(graph)) {
log.debug('Found graph %s', graph.value)
log.debug(`Found graph ${graph.value}`)
}
resources.add(graph)
dataset.add($rdf.quad(subject, predicate, object, graph))
}
} catch (e: unknown) {
if (e instanceof Error) {
log.error('Failed to parse %s: %s', relative, e.message)
log.error(`Failed to parse ${relative}: ${e.message}`)
}
}

Expand All @@ -115,11 +115,11 @@ function toGraphs(api: string) {

function isValidDir(dir: string) {
if (!fs.existsSync(dir)) {
log.warn('Skipping path %s which does not exist', dir)
log.warn(`Skipping path ${dir} which does not exist`)
return false
}
if (!fs.statSync(dir).isDirectory()) {
log.warn('Skipping path %s which is not a directory', dir)
log.warn(`Skipping path ${dir} which is not a directory`)
return false
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core/lib/applyUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function applyUpdates(api: string, validDirs: string[], dataset: Da
const destination = new Store()
const relative = path.relative(dir, file)
const baseIRI = getBaseIRI(relative, api)
log.trace('Applying updates from %s', relative)
log.trace(`Applying updates from ${relative}`)
const query = fs.readFileSync(file, 'utf-8')

const algebra = translate(query, { quads: true, baseIRI })
Expand All @@ -35,12 +35,12 @@ export async function applyUpdates(api: string, validDirs: string[], dataset: Da
})
}
results.addAll(destination)
log.debug('Applied updates from %s, added %s triples', relative, destination.size)
log.debug(`Applied updates from ${relative}, added ${destination.size} triples`)
}
}
const result = $rdf.dataset([...dataset, ...results])

log.info('SPARQL updates applied. Triples before: %s. Triples after: %s', store.size, result.size)
log.info(`SPARQL updates applied. Triples before: ${store.size}. Triples after: ${result.size}`)
return result
}

Expand All @@ -51,7 +51,7 @@ function getUpdates(query: Operation) {
case types.DELETE_INSERT:
return [query]
default:
log.warn('Only update queries are supported, got %s', query.type)
log.warn(`Only update queries are supported, got ${query.type}`)
return []
}
}
4 changes: 2 additions & 2 deletions packages/core/lib/fileStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function getPatchedStream(file: string, cwd: string, api: string, resourc
const basePath = new URL(api).pathname
const mediaType = mime.lookup(file)
if (!mediaType) {
log.warn('Could not determine media type for file %s', relative)
log.warn(`Could not determine media type for file ${relative}`)
return null
}

Expand All @@ -64,7 +64,7 @@ export function getPatchedStream(file: string, cwd: string, api: string, resourc
})

if (!parserStream) {
log.warn('Unsupported media type %s from %s', mediaType, relative)
log.warn(`Unsupported media type ${mediaType} from ${relative}`)
}

return parserStream as unknown as Readable | null
Expand Down

0 comments on commit b4bf27e

Please sign in to comment.