Skip to content

src backend services log

KernelDeimos edited this page Jun 11, 2025 · 1 revision

Logging in Services

Services all have a logger available at this.log.

class MyService extends BaseService {
    async init () {
        this.log.info('Hello, Logger!');
    }
}

There are multiple "log levels", similar to logrus or other common logging libraries.

class MyService extends BaseService {
    async init () {
        this.log.info('I\'m just a regular log.');
        this.log.debug('I\'m only for developers.');
        this.log.warn('It is statistically unlikely I will be awknowledged.');
        this.log.error('Something is broken! Pay attention!');
        this.log.noticeme('This will be noticed, unlike warnings. Use sparingly.');
        this.log.system('I am a system event, like shutdown.');
        this.log.tick('A periodic behavior like cache pruning is occurring.');
    }
}

Log methods can take a second parameter, an object specifying fields.

class MyService extends BaseService {
    async init () {
        this.log.info('I have fields!', {
            why: "why not",
            random_number: 1, // chosen by coin toss, guarenteed to be random
        });
    }
}

General

API

Concepts

Types

For Contributors

Extensions

Devmeta

Planning

Self_hosters

Src

Backend

A_and_A

For Contributors

Features

Lists_of_things

Modules

Puterai

Notes

Services

Src

Modules
Puterai

####### For Contributors

Test_drivers

Gui

Phoenix

Tools

Api_tester

Uncategorized

Clone this wiki locally