Your Magic log
The log component allows you to browse your server’s log. When an important event occurs in Magic, a log entry will typically be created describing the event. Examples of such events are when users are logging in, or errors are occuring in the system for some reasons.
You can also filter your server’s log, looking for specific items, to find bugs happening as your system is being used. Notice, if you created a cloudlet at AINIRO.IO, by default all log entries older than 2 weeks will be automatically deleted to avoid exhausting your cloudlet’s persistent storage.
Creating your own log items from Hyperlambda
You can create your own log entries using Hyperlambda code such as the following.
log.info:Something important happened
what:Something
importance:High
In the above example we are creating an “info” type of log entry, and the “Something important happened” will become the item’s sub-type, while the [what] and [importance] parts becomes meta data associated with your log entry. If you execute the above Hyperlambda using your dashboard’s “Eval” component you can see your log entry in your “Log” component at the top afterwards. There are 4 types of log entries you can create by default.
- [log.debug] - These are debug log entries intended for helping you debug your modules and components
- [log.info] - These are information types of entries providing information about important things occurring in your system
- [log.error] - These are errors and logs when an error occurs in your system
- [log.fatal] - These are fatal errors that prevents your system from working correctly
Configuring logging
Your server has a “log level” setting that decides how much it should log. This is an incrementally
increasing value starting at “debug” and ending at “off”. The latter implying logging is turned off.
You can change this “log level” by changing your magic:logging:level
configuration setting. The log level
declares at what “level” your server will insert log entries. For instance, typically when debugging you want
to set the level at “debug”, while in a production environment you want to increase it to (at least) “info”
to avoid flooding your server with debug log entries. This implies that in your debug environment you will see
all log entries, including your debug log entries - While in production Magic won’t create log entries for
debug log items.
Log internals
By default log items will be persisted into your magic “log_entries” database table, but this can be changed. The magic.lambda.logging project is what encapsulates the logging related slots in Hyperlambda.