Tachybase logging is based on Winston encapsulation. By default, Tachybase divides logs into API request logs, system runtime logs, and SQL execution logs. API request logs and SQL execution logs are printed by the application internally. Plugin developers typically only need to print system runtime logs related to their plugins.
This documentation mainly introduces how to create and print logs when developing plugins.
Tachybase provides print methods for system runtime logs. Logs are printed according to specified fields and simultaneously output to specified files.
The above methods all follow the usage below:
The first parameter is the log message, and the second parameter is an optional metadata object, which can be any key-value pair. Among them, module, submodule, and method will be extracted as separate fields, and the remaining fields will be placed in the meta field.
If you want to use the system's default print method but don't want to output to the default file, you can use createSystemLogger to create a custom system log instance.
If you don't want to use the system's provided print methods and want to use Winston's native methods, you can create logs through the following methods.
createLoggeroptions extends the original winston.LoggerOptions.
transports - You can use 'console' | 'file' | 'dailyRotateFile' for preset output methods.format - You can use 'logfmt' | 'json' | 'delimiter' for preset print formats.app.createLoggerIn multi-application scenarios, sometimes we want to customize the output directory and file, which can be output to the current application name's directory.
plugin.createLoggerUsage and use case same as app.createLogger.