Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

[Question] showing sql queries when testing or log to test.log #519

Closed
u007 opened this issue Jul 14, 2017 · 6 comments
Closed

[Question] showing sql queries when testing or log to test.log #519

u007 opened this issue Jul 14, 2017 · 6 comments

Comments

@u007
Copy link
Member

u007 commented Jul 14, 2017

hi,

how do i force test environment to generate log/test.log?
LogDir in opts does not work

thanks

@markbates
Copy link
Member

So Buffalo uses https://github.com/sirupsen/logrus under the covers. So you can either create a new logger:

app = buffalo.Automatic(buffalo.Options{
  Env:         ENV,
  SessionName: "_toodo_session",
  Logger: ....
})

or you can set the output to something else:

App().Logger.Out = someFile

@u007
Copy link
Member Author

u007 commented Jul 20, 2017

hi @markbates
where do i find the code that prints out [POP] sql sattements in log?

@u007
Copy link
Member Author

u007 commented Jul 20, 2017

iam getting this when callling

App().Logger.Out = file
App().Options.Logger.Out undefined (type buffalo.Logger has no field or method Out)

@markbates
Copy link
Member

Sorry, my bad. The logger is an interface, so you'd have to cast it.

@u007
Copy link
Member Author

u007 commented Jul 21, 2017

Do you want me to submit a uber-go/zap version of buffalo logger ?
it has coloring and can support multiple output.

but i couldnt figure where to fix logging for [POP] to use zap

@ajoses
Copy link

ajoses commented Oct 26, 2018

Sorry, my bad. The logger is an interface, so you'd have to cast it.

Hi,

I'm trying to log to file, I found this solution, however, I'm unable to do it, this is my last attemp:

	fieldLogger := app.Logger.(logrus.FieldLogger)
	logg := fieldLogger.(*logrus.Entry)
	logg.Logger.SetOutput(os.Stdout)

but after running it I get a message:
panic: interface conversion: buffalo.logrusWrapper is not logrus.FieldLogger: missing method WithField

I'm relative new to golang and I know it something about the interfaces, but I don't get it yet.

Any advice would be helpful

Thanks, awesome project!

Arnulfo José

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants