These are the basic logging methods. These are all available directly on Tyr as well.
opts is a list of the following:
Option | Notes |
---|---|
string | The log message. |
Error | An Error or its subclasses. The stack trace will be logged as well. The log message will default to this unless a message is provided directly. |
object | An object which can contain any of the fields in the Log collection. |
Tyranid will automatically log the timestamp, details about the request (method, path, query string, duration, user agent, ...), and so on.
Examples:
Tyr.info('a test message')
Tyr.warn('a log message', { e: 'http' });
Tyr.warn({ e: 'http', m: 'a log message' });
Tyr.fatal({ e: 'http', m: 'a log message' }, new Error())
Use Log.mixin() to add custom Log fields that you would like to record.
For example, say you wanted to store a "zone" property on log messages that was a link to a "Zone" collection:
Tyr.Log.mixin({
fields: {
zone: { link: 'zone' }
}
});
You could then make log() calls referencing the new property:
Tyr.log({ m: 'my log message', zone: myZone })