{"repo":"simukti/sqldb-logger","free":true,"listed":false,"github":"https://github.com/simukti/sqldb-logger","clone":"git clone https://github.com/simukti/sqldb-logger.git","description":"A logger for Go SQL database driver without modifying existing *sql.DB stdlib usage.","language":"Go","stars":379,"topics":["golang","go","sql","logger","database","db","query","sql-logger","sqldb-logger"],"license":"MIT","category":"databases-storage","readme_excerpt":"SQLDB-Logger A logger for Go SQL database driver without modify existing sql.DB stdlib usage. Colored console writer output above only for sample/development FEATURES - Leveled, detailed and configurable logging. - Keep using (or re-use existing) sql.DB as is. - Bring your own logger backend via simple log interface. - Trackable log output: - Every call has its own unique ID. - Prepared statement and execution will have same ID. - On execution/result error, it will include the query, arguments, params, and related IDs. INSTALL Version pinning using dependency manager such as Mod or Dep is highly recommended. USAGE As a start, Logger is just a simple interface: There are 4 included basic implementation that uses well-known JSON structured logger for quickstart: - Zerolog adapter: Using rs/zerolog as its logger. - Onelog adapter: Using francoispqt/onelog as its logger. - Zap adapter: Using uber-go/zap as its logger. - Logrus adapter: Using sirupsen/logrus as its logger. Note: those adapters does not use given context , you need to modify it and adjust with your needs. (example: add http request id/whatever value from context to query log when you call QueryerContext and ExecerContext methods) Then for that logger to works, you need to integrate with a compatible driver which will be used by sql.DB . INTEGRATE WITH EXISTING SQL DB DRIVER Re-use from existing sql.DB driver, this is the simplest way: For example, from: To: That's it, all sql.DB interaction now logged. INTEGRATE WI","default_branch":null,"files":null,"tree":[],"storefront":"/r/simukti","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/simukti/sqldb-logger/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}