Logs messages to a database table.
This project is licensed under the GNU General Public License version 3 (GPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/gpl-3.0.en.html
For commercial use, please use my contact page to obtain a commercial license.
go get -u github.com/dracory/logstore
logStore, err = logstore.NewStore(logstore.NewStoreOptions{
DB: databaseInstance,
LogTableName: "log",
AutomigrateEnabled: true,
})
if err != nil {
panic(error.Error())
}logStore.Info("Hello")
// with additional context
logStore.InfoWithContext("Hello", map[string]string{
"name": "John Doe"
})As slog is the now official logger in golang, LogStore provides a SlogHandler.
Logger = *slog.New(logstore.NewSlogHandler(&LogStore))
logger.Info("Hello", "name", "John Doe")- LevelTrace - Something very low level
- LevelDebug - Useful debugging information
- LevelInfo - Something noteworthy happened!
- LevelWarn - You should probably take a look at this
- LevelError - Something failed but I'm not quitting
- LevelFatal - Bye. Calls os.Exit(1) after logging
- LevelPanic - I'm bailing. Calls panic() after logging
2024.09.23 - Added a SlogHandler
2023.07.19 - Updated instance creation to use options struct
2022.06.26 - Updated dependencies
2021.12.21 - Added LICENSE
2021.12.21 - Added test badge
2021.12.21 - Added support for DB dialects
2021.12.21 - Removed GORM dependency and moved to the standard library