Skip to content

Logging

Iridium has its own basic internal logger. This allows you log out which routes are registered, debugging information for development, and assert on failed conditionals in development mode. This offers you some optional insights into how Iridium is working without requiring you to fork our library and add your own log statements.

You can easily override our logger with your own custom or third-party logger. Satisfy our interface and register your logger in your initilization logic

INFO

Do I need log outputs from Iridium at all?

No it's not required and can be silenced

  • If you'd prefer to keep your logs clear of our debugging or initilization logs, you can set the logger level to 0 and all logs produced by Iridium will be ignored.
  • Our logger is only really useful if you need to understand more about how Iridium is working. Logging out all bootstrapping calls can be useful if you're doing advanced overriding for example. Or if you need a better picture at all routes Iridium registered for you during initlization.

Our Logger

You can see the source code for our basic logger (which just wraps the go log library), here.

We have four levels:

  • Debug
  • Info
  • Warn
  • Error

We have a special additional level called Assert that will log and panic your application in development mode, and log errors in production mode. This is used when for example, you critically misconfigure a part of your application and need to be warned/prevented from running your app unless this error is resolved. We use Assert religiously inside Iridium.

Bringing your own logger

Take a look at our ILogger interface (here), create a basic logger_adapter.go

file in your application and satisfy the interface while calling out to your own custom logger.

You can then register your logger in place of ours via:

go
import "github.com/iridiumgo/iridium/core/logger"

// some method during initilization
func InitLogger() {
    logger.SetLogger(myCustomLogger)
    // myCustomLogger is a struct that implements our
    // basic ILogger interface
}

Released under the MIT License.