Add incredibly powerful Machine Learning to your Sync Server via Realm Object Server and LogDNA! Proactively manage your ROS production environment in real time.
- Run
npm install
oryarn
- Create a file called
creds.json
right next topackage.json
{
"LOG_DNA_INGESTION_KEY": "YOUR LOG DNA INGESTION KEY" // replace your key
}
- Run
npm start
- Go to your dashbaord and view your logs on https://app.logdna.com/
Voila! Powerful Realtime Logging with Machine Learning and Search Capabilities.
- import
Logger
fromrealm-object-server
import { Logger } from 'realm-object-server'
- Subclass it and override the
log
event
class LogDNALogger extends ROSLogger {
constructor(){
super()
}
log(level: string, msg: string, ctx?: object) {
console.log(`${level}: ${msg}`)
}
}
- Add your custom logging code in the log method. In this case it's with LogDNA:
const LogDNA = require('logdna')
const logDNALogger = LogDNA.setupDefaultLogger(ingestionKey, {
hostname: 'locahost'
})
log(level: string, msg: string, ctx?: object) {
console.log(`${level}: ${msg}`) // lets print to our console
logDNALogger.log(`msg`, { level: level })
}
Unfortunately LogDNA doesn't come with a TypeScript definition :-(
- Feed it into the server!
server.start({
dataPath: path.join(__dirname, '../data'),
logger: new LogDNALogger()
})