sdomino/scribble

not found 404 and missing open

Closed this issue · 2 comments

The following is not found:
godoc.org / github.com/nanobox-io/golang-hatchet
from:

For an example of a qualified logger see here.

Using a nil Logger results in lumber for a console log, ok, for playing around.

Also, there isn't an Open for an existing database, so something like this would be nice:

// Open an existing scribble database at the desired directory location, and
// return a *Driver to then use for interacting with the database
func Open(dir string, logger Logger) (driver *Driver, err error) {
    dir = filepath.Clean(dir)

    // ensure the database location does exist
    if _, err := os.Stat(dir); err != nil {
        fmt.Printf("Database, '%s' does not exist.\n", dir)
        os.Exit(1)
    }

    if logger == nil {
        logger = lumber.NewConsoleLogger(lumber.INFO)
    }

    driver = &Driver{
        dir:     dir,
        mutexes: make(map[string]sync.Mutex),
        log:     logger,
    }

    logger.Info("Opening scribble database at '%v'...\n", dir)

    return driver, nil
}

... or perhaps that isn't a valid use case (well, it is for me).
Thanks for scribble.

Open... thats a great idea :), I'll work on getting that in first thing on monday.

As for hatchet, we decided that project isn't necessary so we discontinued it. I thought I removed all reference to it from the source, but I might have missed something. I'll comb through again and catch anything I missed.

A "qualified logger" is now anything that satisfies the interface at the top of scribble.go.

@cleesmith thank you for submitting this. This issue has been addressed here (https://github.com/nanobox-io/golang-scribble/pull/8). Now you can simply specify an existing database on New and it will use it if it exists, or create it if it doesn't.