Skip to content

Allow the user to customize the stack depth to skip.#128

Open
xgfone wants to merge 8 commits into
inconshreveable:masterfrom
xgfone:feature-curstomize-stack
Open

Allow the user to customize the stack depth to skip.#128
xgfone wants to merge 8 commits into
inconshreveable:masterfrom
xgfone:feature-curstomize-stack

Conversation

@xgfone

@xgfone xgfone commented Apr 6, 2017

Copy link
Copy Markdown

This PR removes the hard-coded stack depth to skip. So the user can customize it by the actual demand.

For example, I want to wrap log15.Logger in my struct.

type MyStruct struct {
	logger *log15.Logger

	// Other fields
	// ...
}

func (m *MyStruct) LogInfo(msg string) {
	m.logger.Info(msg)
}

my := MyStruct{
	logger: log15.New().SetStackDepth(1)
}

my.LogInfo("test")

Before this, I have to discard the stack information of log15.Logger and rewrite it myself.

@notzippy

Copy link
Copy Markdown
Contributor

Two things missing on this PR

  • The SetStackDepth is not declared in the interface, therefore is not exposed
  • On the New creation you should set the current StackDepth not use the defaultStackDepth

My additional changes for Revel

@xgfone

xgfone commented Aug 31, 2017

Copy link
Copy Markdown
Author

@notzippy Yes, you are right.

I have merged it from Revel

@xgfone xgfone mentioned this pull request Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants