Spaces:
Sleeping
Sleeping
|
Download src/backend/doc/services/log.md from AZILS/puter-deploy: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/AZILS/puter-deploy/resolve/main/src/backend/doc/services/log.md
- Command line
-
hf download hf://spaces/AZILS/puter-deploy/src/backend/doc/services/log.md
-
curl -L -o log.md https://huggingface.co/spaces/AZILS/puter-deploy/resolve/main/src/backend/doc/services/log.md
1.32 kB
Logging in Services
NOTE: You can, and maybe should, just use console log methods, as they are overriden to log through our logger
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
});
}
}