diff --git a/HISTORY.md b/HISTORY.md index 02af4036..dd909594 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -609,7 +609,8 @@ New Package-level Variables: New Context Methods: -- `Context.IsRecovered()` reports whether the current request was recovered from the [recover middleware](https://github.com/kataras/iris/tree/master/middleware/recover). Also the `iris.IsErrPrivate` function and `iris.ErrPrivate` interface have been introduced. +- `Context.IsDebug() bool` reports whether the application is running under debug/development mode. It is a shortcut of Application.Logger().Level >= golog.DebugLevel. +- `Context.IsRecovered() bool` reports whether the current request was recovered from the [recover middleware](https://github.com/kataras/iris/tree/master/middleware/recover). Also the `iris.IsErrPrivate` function and `iris.ErrPrivate` interface have been introduced. - `Context.RecordBody()` same as the Application's `DisableBodyConsumptionOnUnmarshal` configuration field but registers per chain of handlers. It makes the request body readable more than once. - `Context.IsRecordingBody() bool` reports whether the request body can be readen multiple times. - `Context.ReadHeaders(ptr interface{}) error` binds request headers to "ptr". [Example](https://github.com/kataras/iris/blob/master/_examples/request-body/read-headers/main.go). diff --git a/cache/client/handler.go b/cache/client/handler.go index 202d07e5..b2805685 100644 --- a/cache/client/handler.go +++ b/cache/client/handler.go @@ -93,7 +93,7 @@ func getOrSetKey(ctx *context.Context) string { } // Note: by-default the rules(ruleset pkg) - // explictly ignores the cache handler + // explicitly ignores the cache handler // execution on authenticated requests // and immediately runs the next handler: // if !h.rule.Claim(ctx) ...see `Handler` method. diff --git a/context/application.go b/context/application.go index b1d5b4db..9516743d 100644 --- a/context/application.go +++ b/context/application.go @@ -19,6 +19,11 @@ type Application interface { // Logger returns the golog logger instance(pointer) that is being used inside the "app". Logger() *golog.Logger + // IsDebug reports whether the application is running + // under debug/development mode. + // It's just a shortcut of Logger().Level >= golog.DebugLevel. + // The same method existss as Context.IsDebug() too. + IsDebug() bool // I18nReadOnly returns the i18n's read-only features. I18nReadOnly() I18nReadOnly diff --git a/context/context.go b/context/context.go index 8d5b65c4..a782882c 100644 --- a/context/context.go +++ b/context/context.go @@ -5054,6 +5054,12 @@ func (ctx *Context) Application() Application { return ctx.app } +// IsDebug reports whether the application runs with debug log level. +// It is a shortcut of Application.IsDebug(). +func (ctx *Context) IsDebug() bool { + return ctx.app.IsDebug() +} + const errorContextKey = "iris.context.error" // SetErr is just a helper that sets an error value diff --git a/iris.go b/iris.go index 0f9b2692..9741ce9e 100644 --- a/iris.go +++ b/iris.go @@ -276,6 +276,14 @@ func (app *Application) Logger() *golog.Logger { return app.logger } +// IsDebug reports whether the application is running +// under debug/development mode. +// It's just a shortcut of Logger().Level >= golog.DebugLevel. +// The same method existss as Context.IsDebug() too. +func (app *Application) IsDebug() bool { + return app.logger.Level >= golog.DebugLevel +} + // I18nReadOnly returns the i18n's read-only features. // See `I18n` method for more. func (app *Application) I18nReadOnly() context.I18nReadOnly {