Stone.jsDocs
Paradigm

Essentials

Logging

Logging is a service, injected and used the same way everywhere. You log against a uniform interface with levels; where those logs go, the console, a file, a cloud sink, is a configuration and a backend, not something your code decides.

#Logging from your code

Take the logger from the container and call it by level. Pass structured context as a second argument; a good backend keeps it queryable.

app/Tasks.tsts
constructor ({ logger }) { this.logger = logger }

create (event: IncomingHttpEvent) {
  const task = this.tasks.add(event.get('title'))
  this.logger.info('task created', { id: task.id })
  return task
}

#Levels

Set the minimum level in the app options; anything below it is dropped. Use levels with intent: debug for development detail, info for notable events, warn and error for trouble.

LevelTypeDescription
tracelowestVery fine-grained tracing.
debugDevelopment detail, off in production by default.
infoNotable, expected events.
warnSomething unexpected that did not stop the request.
errorhighestA failure worth attention.
app/Application.tsts
@StoneApp({ name: 'tasks', logger: { level: 'info' } })
export class Application {}

#A custom backend

The logger is an interface; the default writes to the console. Provide your own with defineLogger to route logs to a structured sink, a file, or an observability platform, without changing a single call site.

app/logger.tsts
import { defineLogger } from '@stone-js/core'

export const logger = defineLogger(({ config }) => new JsonLogger({
  level: config.get('stone.logger.level', 'info')
}))

Stone.js

Your app exists in every runtime. Until you run it.

An open-source project by Stone Foundation
Created by Mr. Stone (Evens Pierre)