Skip to main content

Add your own log files

To access the file system, utilize the node fs module. You can create custom log files by following this straightforward example code pattern:

// require the node fs module to get access to file system methods
const fs = gb.method.require('fs')

// create a stream to append data to a text file
const logger = fs.createWriteStream('./gunbot_logs/custom-logs.txt', {flags: 'a'});

// log to file, starting on a new line by using \n
logger.write(`\nLogging some random data ${Math.random()}`)