concrete-eth / concrete-geth

Concrete is a framework for building application-specific rollups on the OP Stack
GNU Lesser General Public License v3.0
47 stars 19 forks source link

feat: Debugf function for better debugging #45

Closed kamuik16 closed 1 month ago

kamuik16 commented 1 month ago

Closes #35

kamuik16 commented 1 month ago

Do let me know if something is not aligned with what you expected. Thanks!

therealbytes commented 1 month ago

This is in the right direction. Just a few issues:

  1. String values should be escaped
  2. Errors should be handled instead of panicking
  3. Debugf should be added to the Environment interface

I think the simplest way to do 1 and 2 for now is to use a logging library for formatting instead of implementing it from scratch. e.g.,

func debugfFormat(msg string, ctx ...interface{}) string {
    var buf bytes.Buffer
    logger := log.NewLogger(log.NewTerminalHandlerWithLevel(&buf, log.LevelDebug, true))
    logger.Debug(msg, ctx...)
    return buf.String()
}
kamuik16 commented 1 month ago

Updated the code @therealbytes ser! Let me know if I did something wrong as I am still somewhat new to Go.