Ask or search…
K
Links

Logging

Tatum comes with a built-in logger which can help you debug your application, display errors and warnings from the inner workings of TatumSDK. You can also use it to log your own messages.
Tatum comes with 3 builtin loggers:
  • TatumDevelopmentLogger - formats messages for easy viewing terminal
  • TatumDevelopmentBrowserLogger - formats messages for browser console
  • TatumProductionLogger - avoids formatting where possible, wraps global console
You can pick choose which logger you use based on your needs.
By default, Tatum will use of the development loggers if you are running in development mode, and TatumProductionLogger if you are running in production mode. Of course, you can override this behaviour by passing your own logger to Tatum SDK.
1
import { TatumSDK, TatumDevelopmentLogger } from "@tatumio/tatum"
2
3
const logger = new TatumDevelopmentLogger()
4
5
const tatum = await TatumSDK.init<Ethereum>({
6
logger,
7
// ...
8
})

Log levels

Tatum supports 5 logging levels in order of severity:
  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
By specifying a certain log level, all logs with a lower severity will be ignored
You can set the log level by passing level to any of our loggers' constructor.
1
import { TatumDevelopmentLogger, LogLevel } from "@tatumio/tatum"
2
3
const logger = new TatumDevelopmentLogger({ level: LogLevel.DEBUG })
4
5
logger.trace("This is a trace message") // will not be logged
6
logger.debug("This is a debug message")
7
logger.error("Ooopsie!")

Bring your own logger

You can also use your own logger, as long as it implements the following interface importable from @tatumio/tatum:
1
interface Logger {
2
trace(...args: any[]): void
3
debug(...args: any[]): void
4
info(...args: any[]): void
5
warn(...args: any[]): void
6
error(...args: any[]): void
7
}
Many popular off-the-shelf loggers such as pino, loglevel or log4js already do so! You can use them without any additional configuration
Alternatively, you can implement it yourself:
1
const myLogger = {
2
trace(...args) {},
3
debug(...args) {},
4
info(...args) {},
5
warn(...args) {},
6
error(...args) {},
7
}
8
9
const tatum = await TatumSDK.init<Ethereum>({
10
network: Network.ETHEREUM,
11
logger: myLogger,
12
})
© Tatum Technology, LLC