Commits

Paul Ruane committed 8a7d948

Switched from custom print routine to fmt.

Comments (0)

Files changed (20)

src/tmsu/cli/cli.go

 	}
 
 	if options.HasOption("--verbose") {
-		log.Verbose = true
+		log.Verbosity = 2
 	}
 	if dbOption := options.Get("--database"); dbOption != nil && dbOption.Argument != "" {
 		database.Path = dbOption.Argument

src/tmsu/cli/copy.go

 		return fmt.Errorf("a tag with name '%v' already exists.", destTagName)
 	}
 
-	log.Suppf("copying tag '%v' to '%v'.", sourceTagName, destTagName)
+	log.Infof(2, "copying tag '%v' to '%v'.", sourceTagName, destTagName)
 
 	if _, err = store.CopyTag(sourceTag.Id, destTagName); err != nil {
 		return fmt.Errorf("could not copy tag '%v' to '%v': %v", sourceTagName, destTagName, err)

src/tmsu/cli/delete.go

 		return fmt.Errorf("no such tag '%v'.", tagName)
 	}
 
-	log.Suppf("finding files tagged '%v'.", tagName)
+	log.Infof(2, "finding files tagged '%v'.", tagName)
 
 	fileTags, err := store.FileTagsByTagId(tag.Id)
 	if err != nil {
 		return fmt.Errorf("could not retrieve taggings for tag '%v': %v", tagName, err)
 	}
 
-	log.Suppf("removing applications of tag '%v'.", tagName)
+	log.Infof(2, "removing applications of tag '%v'.", tagName)
 
 	err = store.RemoveFileTagsByTagId(tag.Id)
 	if err != nil {
 		return fmt.Errorf("could not remove taggings for tag '%v': %v", tagName, err)
 	}
 
-	log.Suppf("removing tags implications involving tag '%v'.", tagName)
+	log.Infof(2, "removing tags implications involving tag '%v'.", tagName)
 
 	err = store.RemoveImplicationsForTagId(tag.Id)
 	if err != nil {
 		return fmt.Errorf("could not remove tag implications involving tag '%v': %v", tagName, err)
 	}
 
-	log.Suppf("deleting tag '%v'.", tagName)
+	log.Infof(2, "deleting tag '%v'.", tagName)
 
 	err = store.DeleteTag(tag.Id)
 	if err != nil {
 		return fmt.Errorf("could not delete tag '%v': %v", tagName, err)
 	}
 
-	log.Suppf("identifying files left untagged as a result of tag deletion.")
+	log.Infof(2, "identifying files left untagged as a result of tag deletion.")
 
 	removedFileCount := 0
 	for _, fileTag := range fileTags {
 		}
 	}
 
-	log.Suppf("removed %v untagged files.", removedFileCount)
+	log.Infof(2, "removed %v untagged files.", removedFileCount)
 
 	return nil
 }

src/tmsu/cli/dupes.go

 	}
 	defer store.Close()
 
-	log.Supp("identifying duplicate files.")
+	log.Info(2, "identifying duplicate files.")
 
 	fileSets, err := store.DuplicateFiles()
 	if err != nil {
 		return fmt.Errorf("could not identify duplicate files: %v", err)
 	}
 
-	log.Suppf("found %v sets of duplicate files.", len(fileSets))
+	log.Infof(2, "found %v sets of duplicate files.", len(fileSets))
 
 	for index, fileSet := range fileSets {
 		if index > 0 {
-			log.Print()
+			fmt.Print()
 		}
 
-		log.Printf("Set of %v duplicates:", len(fileSet))
+		fmt.Printf("Set of %v duplicates:", len(fileSet))
 
 		for _, file := range fileSet {
 			relPath := _path.Rel(file.Path())
-			log.Printf("  %v", relPath)
+			fmt.Printf("  %v", relPath)
 		}
 	}
 
 
 	first := true
 	for _, path := range paths {
-		log.Suppf("%v: identifying duplicate files.", path)
+		log.Infof(2, "%v: identifying duplicate files.", path)
 
 		fp, err := fingerprint.Create(path)
 		if err != nil {
 			if first {
 				first = false
 			} else {
-				log.Print()
+				fmt.Print()
 			}
 
-			log.Printf("%v:", path)
+			fmt.Printf("%v:", path)
 
 			for _, dupe := range dupes {
 				relPath := _path.Rel(dupe.Path())
-				log.Printf("  %v", relPath)
+				fmt.Printf("  %v", relPath)
 			}
 		} else {
 			for _, dupe := range dupes {
 				relPath := _path.Rel(dupe.Path())
-				log.Print(relPath)
+				fmt.Print(relPath)
 			}
 		}
 	}

src/tmsu/cli/files.go

 	}
 	defer store.Close()
 
-	log.Supp("retrieving all files from database.")
+	log.Info(2, "retrieving all files from database.")
 
 	files, err := store.Files()
 	if err != nil {
 	}
 	defer store.Close()
 
-	log.Supp("parsing query")
+	log.Info(2, "parsing query")
 
 	expression, err := query.Parse(queryText)
 	if err != nil {
 		return err
 	}
 
-	log.Supp("checking tag names")
+	log.Info(2, "checking tag names")
 
 	tagNames := query.TagNames(expression)
 	tags, err := store.TagsByNames(tagNames)
 		}
 	}
 
-	log.Supp("querying database")
+	log.Info(2, "querying database")
 
 	files, err := store.QueryFiles(expression)
 	if err != nil {
 	}
 
 	if showCount {
-		log.Print(len(tree.Paths()))
+		fmt.Print(len(tree.Paths()))
 	} else {
 		for _, absPath := range tree.Paths() {
 			relPath := path.Rel(absPath)
 
 			if print0 {
-				log.Print0(relPath)
+				fmt.Printf("%v\000", relPath)
 			} else {
-				log.Print(relPath)
+				fmt.Print(relPath)
 			}
 		}
 	}

src/tmsu/cli/help.go

 package cli
 
 import (
+	"fmt"
 	"math"
 	"sort"
 	"strconv"
-	"tmsu/log"
 )
 
 var HelpCommand = Command{
 }
 
 func summary() {
-	log.Print("TMSU")
-	log.Print()
+	fmt.Println("TMSU")
+	fmt.Println()
 
 	var maxWidth int = 0
 	commandNames := make([]string, 0, len(helpCommands))
 			continue
 		}
 
-		log.Printf("  %-"+strconv.Itoa(maxWidth)+"v  %v", command.Name, commandSummary)
+		fmt.Printf("  %-"+strconv.Itoa(maxWidth)+"v  %v\n", command.Name, commandSummary)
 	}
 
-	log.Print()
+	fmt.Println()
 
-	log.Print("Global options:")
-	log.Print()
+	fmt.Println("Global options:")
+	fmt.Println()
 
 	for _, option := range globalOptions {
-		log.Printf("  %v, %v: %v", option.ShortName, option.LongName, option.Description)
+		fmt.Printf("  %v, %v: %v\n", option.ShortName, option.LongName, option.Description)
 	}
 
-	log.Print()
+	fmt.Println()
 }
 
 func listCommands() {
 	sort.Strings(commandNames)
 
 	for _, commandName := range commandNames {
-		log.Print(commandName)
+		fmt.Println(commandName)
 	}
 }
 
 func describeCommand(commandName string) {
 	command := helpCommands[commandName]
 	if command == nil {
-		log.Printf("No such command '%v'.", commandName)
+		fmt.Printf("No such command '%v'.\n", commandName)
 		return
 	}
 
-	log.Print(command.Description)
+	fmt.Println(command.Description)
 
 	if len(command.Options) > 0 {
-		log.Print()
+		fmt.Println()
 
-		log.Print("Options:")
-		log.Print()
+		fmt.Println("Options:")
+		fmt.Println()
 
 		for _, option := range command.Options {
-			log.Printf("  %v, %v: %v", option.ShortName, option.LongName, option.Description)
+			fmt.Printf("  %v, %v: %v\n", option.ShortName, option.LongName, option.Description)
 		}
 	}
 }

src/tmsu/cli/imply.go

 // unexported
 
 func listImplications(store *storage.Storage) error {
-	log.Suppf("retrieving tag implications.")
+	log.Infof(2, "retrieving tag implications.")
 
 	implications, err := store.Implications()
 	if err != nil {
 		return fmt.Errorf("no such tag '%v'.", impliedTagName)
 	}
 
-	log.Suppf("adding tag implication of '%v' to '%v'.", tagName, impliedTagName)
+	log.Infof(2, "adding tag implication of '%v' to '%v'.", tagName, impliedTagName)
 
 	if err = store.AddImplication(tag.Id, impliedTag.Id); err != nil {
 		return fmt.Errorf("could not add tag implication of '%v' to '%v': %v", tagName, impliedTagName, err)
 		return fmt.Errorf("no such tag '%v'.", impliedTagName)
 	}
 
-	log.Suppf("removing tag implication of '%v' to '%v'.", tagName, impliedTagName)
+	log.Infof(2, "removing tag implication of '%v' to '%v'.", tagName, impliedTagName)
 
 	if err = store.RemoveImplication(tag.Id, impliedTag.Id); err != nil {
 		return fmt.Errorf("could not add delete tag implication of '%v' to '%v': %v", tagName, impliedTagName, err)

src/tmsu/cli/merge.go

 			return fmt.Errorf("no such tag '%v'.", sourceTagName)
 		}
 
-		log.Suppf("finding files tagged '%v'.", sourceTagName)
+		log.Infof(2, "finding files tagged '%v'.", sourceTagName)
 
 		fileTags, err := store.FileTagsByTagId(sourceTag.Id)
 		if err != nil {
 			return fmt.Errorf("could not retrieve files for tag '%v': %v", sourceTagName, err)
 		}
 
-		log.Suppf("applying tag '%v' to these files.", destTagName)
+		log.Infof(2, "applying tag '%v' to these files.", destTagName)
 
 		for _, fileTag := range fileTags {
 			_, err = store.AddFileTag(fileTag.FileId, destTag.Id)
 			}
 		}
 
-		log.Suppf("untagging files '%v'.", sourceTagName)
+		log.Infof(2, "untagging files '%v'.", sourceTagName)
 
 		if err := store.RemoveFileTagsByTagId(sourceTag.Id); err != nil {
 			return fmt.Errorf("could not remove all applications of tag '%v': %v", sourceTagName, err)
 		}
 
-		log.Suppf("updating tag implications involving tag '%v'.", sourceTagName)
+		log.Infof(2, "updating tag implications involving tag '%v'.", sourceTagName)
 
 		if err := store.UpdateImplicationsForTagId(sourceTag.Id, destTag.Id); err != nil {
 			return fmt.Errorf("could not update tag implications involving tag '%v': %v", sourceTagName, err)
 		}
 
-		log.Suppf("deleting tag '%v'.", sourceTagName)
+		log.Infof(2, "deleting tag '%v'.", sourceTagName)
 
 		err = store.DeleteTag(sourceTag.Id)
 		if err != nil {

src/tmsu/cli/mount.go

 }
 
 func listMounts() error {
-	log.Supp("retrieving mount table.")
+	log.Info(2, "retrieving mount table.")
 
 	mt, err := vfs.GetMountTable()
 	if err != nil {
 	}
 
 	if len(mt) == 0 {
-		log.Supp("mount table is empty.")
+		log.Info(2, "mount table is empty.")
 	}
 
 	for _, mount := range mt {
-		log.Printf("'%v' at '%v'", mount.DatabasePath, mount.MountPath)
+		fmt.Printf("'%v' at '%v'", mount.DatabasePath, mount.MountPath)
 	}
 
 	return nil
 		return fmt.Errorf("%v: database does not exist.")
 	}
 
-	log.Suppf("spawning daemon to mount VFS for database '%v' at '%v'.", databasePath, mountPath)
+	log.Infof(2, "spawning daemon to mount VFS for database '%v' at '%v'.", databasePath, mountPath)
 
 	args := []string{"vfs", databasePath, mountPath, "--options=" + mountOptions}
 	daemon := exec.Command(os.Args[0], args...)
 		return fmt.Errorf("could not start daemon: %v", err)
 	}
 
-	log.Supp("sleeping.")
+	log.Info(2, "sleeping.")
 
 	const HALF_SECOND = 500000000
 	time.Sleep(HALF_SECOND)
 
-	log.Supp("checking whether daemon started successfully.")
+	log.Info(2, "checking whether daemon started successfully.")
 
 	var waitStatus syscall.WaitStatus
 	var rusage syscall.Rusage

src/tmsu/cli/rename.go

 		return fmt.Errorf("tag '%v' already exists.", destTagName)
 	}
 
-	log.Suppf("renaming tag '%v' to '%v'.", sourceTagName, destTagName)
+	log.Infof(2, "renaming tag '%v' to '%v'.", sourceTagName, destTagName)
 
 	_, err = store.RenameTag(sourceTag.Id, destTagName)
 	if err != nil {

src/tmsu/cli/repair.go

 //- unexported
 
 func repairDatabase(store *storage.Storage, pretend, force bool) error {
-	log.Supp("retrieving all files from the database.")
+	log.Infof(2, "retrieving all files from the database.")
 
 	files, err := store.Files()
 	if err != nil {
 		absPaths[index] = absPath
 	}
 
-	log.Suppf("identifying top-level paths.")
+	log.Infof(2, "identifying top-level paths.")
 
 	err := repairFiles(store, absPaths, pretend, force)
 	if err != nil {
 	}
 
 	for path, _ := range untagged {
-		log.Infof("%v: untagged", path)
+		log.Infof(1, "%v: untagged", path)
 	}
 
 	//TODO cleanup: any files that have no tags: remove
 type databaseFileMap map[string]entities.File
 
 func determineStatuses(fsPaths fileInfoMap, dbPaths databaseFileMap) (tagged databaseFileMap, untagged fileInfoMap, modified fileIdAndInfoMap, missing databaseFileMap) {
-	log.Supp("determining file statuses")
+	log.Infof(2, "determining file statuses")
 
 	tagged = make(databaseFileMap, 100)
 	untagged = make(fileInfoMap, 100)
 }
 
 func repairModified(store *storage.Storage, modified fileIdAndInfoMap, pretend bool) error {
-	log.Supp("repairing modified files")
+	log.Infof(2, "repairing modified files")
 
 	for path, fileIdAndStat := range modified {
 		fileId := fileIdAndStat.fileId
 		stat := fileIdAndStat.stat
 
-		log.Infof("%v: modified", path)
+		log.Infof(1, "%v: modified", path)
 
 		fingerprint, err := fingerprint.Create(path)
 		if err != nil {
 }
 
 func repairMoved(store *storage.Storage, missing databaseFileMap, untagged fileInfoMap, pretend bool) error {
-	log.Supp("repairing moved files")
+	log.Infof(2, "repairing moved files")
 
 	moved := make([]string, 0, 10)
 
 	for path, dbFile := range missing {
-		log.Suppf("%v: searching for new location", path)
+		log.Infof(2, "%v: searching for new location", path)
 
 		for candidatePath, stat := range untagged {
 			if stat.Size() == dbFile.Size {
 				}
 
 				if fingerprint == dbFile.Fingerprint {
-					log.Infof("%v: moved to %v", path, candidatePath)
+					log.Infof(1, "%v: moved to %v", path, candidatePath)
 
 					moved = append(moved, path)
 
 				return fmt.Errorf("%v: could not delete file: %v", path, err)
 			}
 
-			log.Infof("%v: removed", path)
+			log.Infof(1, "%v: removed", path)
 		} else {
-			log.Infof("%v: missing", path)
+			log.Infof(1, "%v: missing", path)
 		}
 	}
 

src/tmsu/cli/stats.go

 import (
 	"fmt"
 	"math"
-	"tmsu/log"
 	"tmsu/storage"
 )
 
 		averageFilesPerTag = float32(fileTagCount) / float32(tagCount)
 	}
 
-	log.Print("BASICS")
-	log.Print()
-	log.Printf("  Tags:     %v", tagCount)
-	log.Printf("  Files:    %v", fileCount)
-	log.Printf("  Taggings: %v", fileTagCount)
-	log.Print()
+	fmt.Println("BASICS")
+	fmt.Println()
+	fmt.Printf("  Tags:     %v\n", tagCount)
+	fmt.Printf("  Files:    %v\n", fileCount)
+	fmt.Printf("  Taggings: %v\n", fileTagCount)
+	fmt.Println()
 
-	log.Print("AVERAGES")
-	log.Print()
-	log.Printf("  Tags per file: %1.2f", averageTagsPerFile)
-	log.Printf("  Files per tag: %1.2f", averageFilesPerTag)
-	log.Print()
+	fmt.Println("AVERAGES")
+	fmt.Println()
+	fmt.Printf("  Tags per file: %1.2f\n", averageTagsPerFile)
+	fmt.Printf("  Files per tag: %1.2f\n", averageFilesPerTag)
+	fmt.Println()
 
 	topTags, err := store.TopTags(10)
 	if err != nil {
 		return fmt.Errorf("could not retrieve top tags: %v", err)
 	}
 
-	log.Printf("TOP TAGS")
-	log.Print()
+	fmt.Println("TOP TAGS")
+	fmt.Println()
 	maxLength := 0
 	maxCountWidth := 0
 	for _, tag := range topTags {
 		}
 	}
 	for _, tag := range topTags {
-		log.Printf("  %*v %*s", maxCountWidth, tag.FileCount, -maxLength, tag.Name)
+		fmt.Printf("  %*v %*s\n", maxCountWidth, tag.FileCount, -maxLength, tag.Name)
 	}
-	log.Print()
+	fmt.Println()
 
 	return nil
 }

src/tmsu/cli/status.go

 	}
 	defer store.Close()
 
-	log.Supp("retrieving all files from database.")
+	log.Info(2, "retrieving all files from database.")
 
 	files, err := store.Files()
 	if err != nil {
 		}
 
 		if !dirOnly {
-			log.Suppf("%v: retrieving files from database.", path)
+			log.Infof(2, "%v: retrieving files from database.", path)
 
 			files, err := store.FilesByDirectory(absPath)
 			if err != nil {
 func statusCheckFile(file *entities.File, report *StatusReport) error {
 	relPath := path.Rel(file.Path())
 
-	log.Suppf("%v: checking file status.", file.Path())
+	log.Infof(2, "%v: checking file status.", file.Path())
 
 	stat, err := os.Stat(file.Path())
 	if err != nil {
 		switch {
 		case os.IsNotExist(err):
-			log.Suppf("%v: file is missing.", file.Path())
+			log.Infof(2, "%v: file is missing.", file.Path())
 
 			report.AddRow(Row{relPath, MISSING})
 			return nil
 		}
 	} else {
 		if stat.Size() != file.Size || stat.ModTime().UTC() != file.ModTime {
-			log.Suppf("%v: file is modified.", file.Path())
+			log.Infof(2, "%v: file is modified.", file.Path())
 
 			report.AddRow(Row{relPath, MODIFIED})
 		} else {
-			log.Suppf("%v: file is unchanged.", file.Path())
+			log.Infof(2, "%v: file is unchanged.", file.Path())
 
 			report.AddRow(Row{relPath, TAGGED})
 		}
 }
 
 func findNewFiles(searchPath string, report *StatusReport, dirOnly bool) error {
-	log.Suppf("%v: finding new files.", searchPath)
+	log.Infof(2, "%v: finding new files.", searchPath)
 
 	relPath := path.Rel(searchPath)
 
 }
 
 func printRow(row Row) {
-	log.Printf("%v %v", string(row.Status), row.Path)
+	fmt.Printf("%v %v", string(row.Status), row.Path)
 }

src/tmsu/cli/tag.go

 		}
 	}
 
-	log.Suppf("retrieving tag implications")
+	log.Infof(2, "retrieving tag implications")
 
 	tagIds := make([]uint, len(tags))
 	for index, tag := range tags {
 		}
 	}
 
-	log.Suppf("%v: applying tags.", file.Path())
+	log.Infof(2, "%v: applying tags.", file.Path())
 
 	if err = store.AddFileTags(file.Id, tagIds); err != nil {
 		return fmt.Errorf("%v: could not apply tags: %v", file.Path(), err)
 }
 
 func addFile(store *storage.Storage, path string, modTime time.Time, size uint, isDir bool) (*entities.File, error) {
-	log.Suppf("%v: adding file.", path)
+	log.Infof(2, "%v: adding file.", path)
 
 	fingerprint, err := fingerprint.Create(path)
 	if err != nil {

src/tmsu/cli/tags.go

 	}
 	defer store.Close()
 
-	log.Supp("retrieving all tags.")
+	log.Info(2, "retrieving all tags.")
 
 	if showCount {
 		count, err := store.TagCount()
 			return fmt.Errorf("could not retrieve tag count: %v", err)
 		}
 
-		log.Print(count)
+		fmt.Print(count)
 	} else {
 		tags, err := store.Tags()
 		if err != nil {
 		}
 
 		for _, tag := range tags {
-			log.Print(tag.Name)
+			fmt.Print(tag.Name)
 		}
 	}
 
 }
 
 func listTagsForPath(store *storage.Storage, path string, showCount bool) error {
-	log.Suppf("%v: retrieving tags.", path)
+	log.Infof(2, "%v: retrieving tags.", path)
 
 	var tags, err = store.TagsForPath(path)
 	if err != nil {
 	}
 
 	if showCount {
-		log.Print(len(tags))
+		fmt.Print(len(tags))
 	} else {
 		for _, tag := range tags {
-			log.Print(tag.Name)
+			fmt.Print(tag.Name)
 		}
 	}
 
 
 func listTagsForPaths(store *storage.Storage, paths []string, showCount bool) error {
 	for _, path := range paths {
-		log.Suppf("%v: retrieving tags.", path)
+		log.Infof(2, "%v: retrieving tags.", path)
 
 		var tags, err = store.TagsForPath(path)
 		if err != nil {
 		}
 
 		if showCount {
-			log.Print(path + ": " + strconv.Itoa(len(tags)))
+			fmt.Print(path + ": " + strconv.Itoa(len(tags)))
 		} else {
-			log.Print(path + ": " + formatTags(tags))
+			fmt.Print(path + ": " + formatTags(tags))
 		}
 	}
 
 	sort.Strings(dirNames)
 
 	for _, dirName := range dirNames {
-		log.Suppf("%v: retrieving tags.", dirName)
+		log.Infof(2, "%v: retrieving tags.", dirName)
 
 		var tags, err = store.TagsForPath(dirName)
 
 		}
 
 		if showCount {
-			log.Print(dirName + ": " + strconv.Itoa(len(tags)))
+			fmt.Print(dirName + ": " + strconv.Itoa(len(tags)))
 		} else {
-			log.Print(dirName + ": " + formatTags(tags))
+			fmt.Print(dirName + ": " + formatTags(tags))
 		}
 	}
 

src/tmsu/cli/unmount.go

 }
 
 func unmount(path string) error {
-	log.Supp("searching path for fusermount.")
+	log.Info(2, "searching path for fusermount.")
 
 	fusermountPath, err := exec.LookPath("fusermount")
 	if err != nil {
 		return fmt.Errorf("could not find 'fusermount': ensure fuse is installed: %v", err)
 	}
 
-	log.Suppf("running: %v -u %v.", fusermountPath, path)
+	log.Infof(2, "running: %v -u %v.", fusermountPath, path)
 
 	process, err := os.StartProcess(fusermountPath, []string{fusermountPath, "-u", path}, &os.ProcAttr{})
 	if err != nil {
 		return fmt.Errorf("could not start 'fusermount': %v", err)
 	}
 
-	log.Supp("waiting for process to exit.")
+	log.Info(2, "waiting for process to exit.")
 
 	processState, err := process.Wait()
 	if err != nil {
 }
 
 func unmountAll() error {
-	log.Supp("retrieving mount table.")
+	log.Info(2, "retrieving mount table.")
 
 	mt, err := vfs.GetMountTable()
 	if err != nil {
 	}
 
 	if len(mt) == 0 {
-		log.Supp("mount table is empty.")
+		log.Info(2, "mount table is empty.")
 	}
 
 	for _, mount := range mt {

src/tmsu/cli/untag.go

 		return fmt.Errorf("%v: file is not tagged.", path)
 	}
 
-	log.Suppf("%v: removing all tags.", file.Path())
+	log.Infof(2, "%v: removing all tags.", file.Path())
 
 	if err := store.RemoveFileTagsByFileId(file.Id); err != nil {
 		return fmt.Errorf("%v: could not remove file's tags: %v", file.Path(), err)
 	}
 
 	for _, tagId := range tagIds {
-		log.Suppf("%v: unapplying tag #%v.", file.Path(), tagId)
+		log.Infof(2, "%v: unapplying tag #%v.", file.Path(), tagId)
 
 		if err := store.RemoveFileTag(file.Id, tagId); err != nil {
 			return fmt.Errorf("%v: could not remove tag #%v: %v", file.Path(), tagId, err)
 
 		for _, childFile := range childFiles {
 			for _, tagId := range tagIds {
-				log.Suppf("%v: unapplying tag #%v.", childFile.Path(), tagId)
+				log.Infof(2, "%v: unapplying tag #%v.", childFile.Path(), tagId)
 
 				if err := store.RemoveFileTag(childFile.Id, tagId); err != nil {
 					return fmt.Errorf("%v: could not remove tag #%v: %v", childFile.Path(), tagId, err)
 }
 
 func removeUntaggedFile(store *storage.Storage, file *entities.File) error {
-	log.Suppf("%v: identifying whether file is tagged.", file.Path())
+	log.Infof(2, "%v: identifying whether file is tagged.", file.Path())
 
 	filetagCount, err := store.FileTagCountByFileId(file.Id)
 	if err != nil {
 	}
 
 	if filetagCount == 0 {
-		log.Suppf("%v: removing untagged file.", file.Path())
+		log.Infof(2, "%v: removing untagged file.", file.Path())
 
 		err = store.RemoveFile(file.Id)
 		if err != nil {

src/tmsu/cli/version.go

 package cli
 
 import (
+	"fmt"
 	"tmsu/common"
-	"tmsu/log"
 )
 
 var VersionCommand = Command{
 }
 
 func versionExec(options Options, args []string) error {
-	log.Print("TMSU", common.Version)
-	log.Print()
-	log.Print(`Copyright © 2011-2013 Paul Ruane.
+	fmt.Print("TMSU", common.Version)
+	fmt.Print()
+	fmt.Print(`Copyright © 2011-2013 Paul Ruane.
 
 This program comes with ABSOLUTELY NO WARRANTY.
 This is free software, and you are welcome to redistribute it under certain conditions.

src/tmsu/log/log.go

 
 var Outfile = os.Stdout
 var Errfile = os.Stderr
-var Verbose = false
+var Verbosity = 1
 
 func Fatal(values ...interface{}) {
 	Warn(values...)
 	fmt.Fprintf(Errfile, format, values...)
 }
 
-func Info(values ...interface{}) {
+func Info(verbosity uint, values ...interface{}) {
 	fmt.Fprintf(Outfile, "tmsu: ")
 	fmt.Fprintln(Outfile, values...)
 }
 
-func Infof(format string, values ...interface{}) {
+func Infof(verbosity uint, format string, values ...interface{}) {
 	format = "tmsu: " + format + "\n"
 	fmt.Fprintf(Outfile, format, values...)
 }
-
-func Supp(values ...interface{}) {
-	if !Verbose {
-		return
-	}
-
-	fmt.Fprintf(Outfile, "tmsu: ")
-	fmt.Fprintln(Outfile, values...)
-}
-
-func Suppf(format string, values ...interface{}) {
-	if !Verbose {
-		return
-	}
-
-	format = "tmsu: " + format + "\n"
-	fmt.Fprintf(Outfile, format, values...)
-}
-
-func Print(values ...interface{}) {
-	fmt.Fprintln(Outfile, values...)
-}
-
-func Printf(format string, values ...interface{}) {
-	format = format + "\n"
-	fmt.Fprintf(Outfile, format, values...)
-}
-
-func Print0(values ...interface{}) {
-	fmt.Fprint(Outfile, values...)
-	fmt.Fprint(Outfile, "\000")
-}
-
-func Print0f(format string, values ...interface{}) {
-	format = format + "\000"
-	fmt.Fprintf(Outfile, format, values...)
-}

src/tmsu/vfs/fusevfs.go

 }
 
 func (vfs FuseVfs) Access(name string, mode uint32, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Access(%v, %v)", name, mode)
-	defer log.Infof("END Access(%v, %v)", name, mode)
+	log.Infof(2, "BEGIN Access(%v, %v)", name, mode)
+	defer log.Infof(2, "END Access(%v, %v)", name, mode)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Chmod(name string, mode uint32, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Chmod(%v, %v)", name, mode)
-	defer log.Infof("BEGIN Chmod(%v, %v)", name, mode)
+	log.Infof(2, "BEGIN Chmod(%v, %v)", name, mode)
+	defer log.Infof(2, "BEGIN Chmod(%v, %v)", name, mode)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Chown(name string, uid uint32, gid uint32, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Chown(%v, %v, %v)", name, uid, gid)
-	defer log.Infof("BEGIN Chown(%v, %v)", name, uid, gid)
+	log.Infof(2, "BEGIN Chown(%v, %v, %v)", name, uid, gid)
+	defer log.Infof(2, "BEGIN Chown(%v, %v)", name, uid, gid)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Create(name string, flags uint32, mode uint32, context *fuse.Context) (nodefs.File, fuse.Status) {
-	log.Infof("BEGIN Create(%v, %v, %v)", name, flags, mode)
-	defer log.Infof("BEGIN Create(%v, %v)", name, flags, mode)
+	log.Infof(2, "BEGIN Create(%v, %v, %v)", name, flags, mode)
+	defer log.Infof(2, "BEGIN Create(%v, %v)", name, flags, mode)
 
 	return nil, fuse.ENOSYS
 }
 
 func (vfs FuseVfs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
-	log.Infof("BEGIN GetAttr(%v)", name)
-	defer log.Infof("END GetAttr(%v)", name)
+	log.Infof(2, "BEGIN GetAttr(%v)", name)
+	defer log.Infof(2, "END GetAttr(%v)", name)
 
 	switch name {
 	case "":
 }
 
 func (vfs FuseVfs) GetXAttr(name string, attr string, context *fuse.Context) ([]byte, fuse.Status) {
-	log.Infof("BEGIN GetXAttr(%v, %v)", name, attr)
-	defer log.Infof("END GetAttr(%v, %v)", name, attr)
+	log.Infof(2, "BEGIN GetXAttr(%v, %v)", name, attr)
+	defer log.Infof(2, "END GetAttr(%v, %v)", name, attr)
 
 	return nil, fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Link(oldName string, newName string, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Link(%v, %v)", oldName, newName)
-	defer log.Infof("END Link(%v, %v)", oldName, newName)
+	log.Infof(2, "BEGIN Link(%v, %v)", oldName, newName)
+	defer log.Infof(2, "END Link(%v, %v)", oldName, newName)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) ListXAttr(name string, context *fuse.Context) ([]string, fuse.Status) {
-	log.Infof("BEGIN ListXAttr(%v)", name)
-	defer log.Infof("END ListXAttr(%v)", name)
+	log.Infof(2, "BEGIN ListXAttr(%v)", name)
+	defer log.Infof(2, "END ListXAttr(%v)", name)
 
 	return nil, fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Mkdir(name string, mode uint32, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Mkdir(%v)", name)
-	defer log.Infof("END Mkdir(%v)", name)
+	log.Infof(2, "BEGIN Mkdir(%v)", name)
+	defer log.Infof(2, "END Mkdir(%v)", name)
 
 	path := vfs.splitPath(name)
 
 }
 
 func (vfs FuseVfs) Mknod(name string, mode uint32, dev uint32, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Mknod(%v)", name)
-	defer log.Infof("END Mknod(%v)", name)
+	log.Infof(2, "BEGIN Mknod(%v)", name)
+	defer log.Infof(2, "END Mknod(%v)", name)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) OnMount(nodeFs *pathfs.PathNodeFs) {
-	log.Infof("BEGIN OnMount()")
-	defer log.Infof("END OnMount()")
+	log.Infof(2, "BEGIN OnMount()")
+	defer log.Infof(2, "END OnMount()")
 }
 
 func (vfs FuseVfs) OnUnmount() {
-	log.Infof("BEGIN OnUnmount()")
-	defer log.Infof("END OnUnmount()")
+	log.Infof(2, "BEGIN OnUnmount()")
+	defer log.Infof(2, "END OnUnmount()")
 }
 
 func (vfs FuseVfs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) {
-	log.Infof("BEGIN Open(%v)", name)
-	defer log.Infof("END Open(%v)", name)
+	log.Infof(2, "BEGIN Open(%v)", name)
+	defer log.Infof(2, "END Open(%v)", name)
 
 	return nil, fuse.ENOSYS
 }
 
 func (vfs FuseVfs) OpenDir(name string, context *fuse.Context) ([]fuse.DirEntry, fuse.Status) {
-	log.Infof("BEGIN OpenDir(%v)", name)
-	defer log.Infof("END OpenDir(%v)", name)
+	log.Infof(2, "BEGIN OpenDir(%v)", name)
+	defer log.Infof(2, "END OpenDir(%v)", name)
 
 	switch name {
 	case "":
 }
 
 func (vfs FuseVfs) Readlink(name string, context *fuse.Context) (string, fuse.Status) {
-	log.Infof("BEGIN Readlink(%v)", name)
-	defer log.Infof("END Readlink(%v)", name)
+	log.Infof(2, "BEGIN Readlink(%v)", name)
+	defer log.Infof(2, "END Readlink(%v)", name)
 
 	path := vfs.splitPath(name)
 	switch path[0] {
 }
 
 func (vfs FuseVfs) RemoveXAttr(name string, attr string, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN RemoveXAttr(%v, %v)", name, attr)
-	defer log.Infof("END RemoveXAttr(%v, %v)", name, attr)
+	log.Infof(2, "BEGIN RemoveXAttr(%v, %v)", name, attr)
+	defer log.Infof(2, "END RemoveXAttr(%v, %v)", name, attr)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Rename(oldName string, newName string, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Rename(%v, %v)", oldName, newName)
-	defer log.Infof("END Rename(%v, %v)", oldName, newName)
+	log.Infof(2, "BEGIN Rename(%v, %v)", oldName, newName)
+	defer log.Infof(2, "END Rename(%v, %v)", oldName, newName)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Rmdir(name string, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Rmdir(%v)", name)
-	defer log.Infof("END Rmdir(%v)", name)
+	log.Infof(2, "BEGIN Rmdir(%v)", name)
+	defer log.Infof(2, "END Rmdir(%v)", name)
 
 	path := vfs.splitPath(name)
 
 }
 
 func (vfs FuseVfs) SetXAttr(name string, attr string, data []byte, flags int, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN SetXAttr(%v, %v)", name, attr)
-	defer log.Infof("END SetXAttr(%v, %v)", name, attr)
+	log.Infof(2, "BEGIN SetXAttr(%v, %v)", name, attr)
+	defer log.Infof(2, "END SetXAttr(%v, %v)", name, attr)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) StatFs(name string) *fuse.StatfsOut {
-	log.Infof("BEGIN StatFs(%v)", name)
-	defer log.Infof("END StatFs(%v)", name)
+	log.Infof(2, "BEGIN StatFs(%v)", name)
+	defer log.Infof(2, "END StatFs(%v)", name)
 
 	return &fuse.StatfsOut{}
 }
 }
 
 func (vfs FuseVfs) Symlink(value string, linkName string, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Symlink(%v, %v)", value, linkName)
-	defer log.Infof("END Symlink(%v, %v)", value, linkName)
+	log.Infof(2, "BEGIN Symlink(%v, %v)", value, linkName)
+	defer log.Infof(2, "END Symlink(%v, %v)", value, linkName)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Truncate(name string, offset uint64, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Truncate(%v)", name)
-	defer log.Infof("END Truncate(%v)", name)
+	log.Infof(2, "BEGIN Truncate(%v)", name)
+	defer log.Infof(2, "END Truncate(%v)", name)
 
 	return fuse.ENOSYS
 }
 
 func (vfs FuseVfs) Unlink(name string, context *fuse.Context) fuse.Status {
-	log.Infof("BEGIN Unlink(%v)", name)
-	defer log.Infof("END Unlink(%v)", name)
+	log.Infof(2, "BEGIN Unlink(%v)", name)
+	defer log.Infof(2, "END Unlink(%v)", name)
 
 	fileId := vfs.parseFileId(name)
 	if fileId == 0 {
 }
 
 func (vfs FuseVfs) topDirectories() ([]fuse.DirEntry, fuse.Status) {
-	log.Infof("BEGIN topDirectories")
-	defer log.Infof("END topDirectories")
+	log.Infof(2, "BEGIN topDirectories")
+	defer log.Infof(2, "END topDirectories")
 
 	entries := []fuse.DirEntry{fuse.DirEntry{Name: tagsDir, Mode: fuse.S_IFDIR},
 		fuse.DirEntry{Name: queriesDir, Mode: fuse.S_IFDIR}}
 }
 
 func (vfs FuseVfs) tagDirectories() ([]fuse.DirEntry, fuse.Status) {
-	log.Infof("BEGIN tagDirectories")
-	defer log.Infof("END tagDirectories")
+	log.Infof(2, "BEGIN tagDirectories")
+	defer log.Infof(2, "END tagDirectories")
 
 	tags, err := vfs.store.Tags()
 	if err != nil {
 }
 
 func (vfs FuseVfs) queriesDirectories() ([]fuse.DirEntry, fuse.Status) {
-	log.Infof("BEGIN queriesDirectories")
-	defer log.Infof("END queriesDirectories")
+	log.Infof(2, "BEGIN queriesDirectories")
+	defer log.Infof(2, "END queriesDirectories")
 
 	queries, err := vfs.store.Queries()
 	if err != nil {
 }
 
 func (vfs FuseVfs) getTagsAttr() (*fuse.Attr, fuse.Status) {
-	log.Infof("BEGIN getTagsAttr")
-	defer log.Infof("END getTagsAttr")
+	log.Infof(2, "BEGIN getTagsAttr")
+	defer log.Infof(2, "END getTagsAttr")
 
 	tagCount, err := vfs.store.TagCount()
 	if err != nil {
 }
 
 func (vfs FuseVfs) getQueryAttr() (*fuse.Attr, fuse.Status) {
-	log.Infof("BEGIN getQueryAttr")
-	defer log.Infof("END getQueryAttr")
+	log.Infof(2, "BEGIN getQueryAttr")
+	defer log.Infof(2, "END getQueryAttr")
 
 	now := time.Now()
 	return &fuse.Attr{Mode: fuse.S_IFDIR | 0755, Nlink: 2, Size: 0, Mtime: uint64(now.Unix()), Mtimensec: uint32(now.Nanosecond())}, fuse.OK
 }
 
 func (vfs FuseVfs) getTaggedEntryAttr(path []string) (*fuse.Attr, fuse.Status) {
-	log.Infof("BEGIN getTaggedEntryAttr(%v)", path)
-	defer log.Infof("END getTaggedEntryAttr(%v)", path)
+	log.Infof(2, "BEGIN getTaggedEntryAttr(%v)", path)
+	defer log.Infof(2, "END getTaggedEntryAttr(%v)", path)
 
 	pathLength := len(path)
 	name := path[pathLength-1]
 }
 
 func (vfs FuseVfs) getQueryEntryAttr(path []string) (*fuse.Attr, fuse.Status) {
-	log.Infof("BEGIN getQueryEntryAttr(%v)", path)
-	defer log.Infof("END getQueryEntryAttr(%v)", path)
+	log.Infof(2, "BEGIN getQueryEntryAttr(%v)", path)
+	defer log.Infof(2, "END getQueryEntryAttr(%v)", path)
 
 	pathLength := len(path)
 	name := path[pathLength-1]
 }
 
 func (vfs FuseVfs) openTaggedEntryDir(path []string) ([]fuse.DirEntry, fuse.Status) {
-	log.Infof("BEGIN openTaggedEntryDir(%v)", path)
-	defer log.Infof("END openTaggedEntryDir(%v)", path)
+	log.Infof(2, "BEGIN openTaggedEntryDir(%v)", path)
+	defer log.Infof(2, "END openTaggedEntryDir(%v)", path)
 
 	tagIds, err := vfs.tagNamesToIds(path)
 	if err != nil {
 }
 
 func (vfs FuseVfs) openQueryEntryDir(path []string) ([]fuse.DirEntry, fuse.Status) {
-	log.Infof("BEGIN openQueryEntryDir(%v)", path)
-	defer log.Infof("END openQueryEntryDir(%v)", path)
+	log.Infof(2, "BEGIN openQueryEntryDir(%v)", path)
+	defer log.Infof(2, "END openQueryEntryDir(%v)", path)
 
 	queryText := path[0]
 	expression, err := query.Parse(queryText)
 }
 
 func (vfs FuseVfs) readTaggedEntryLink(path []string) (string, fuse.Status) {
-	log.Infof("BEGIN readTaggedEntryLink(%v)", path)
-	defer log.Infof("END readTaggedEntryLink(%v)", path)
+	log.Infof(2, "BEGIN readTaggedEntryLink(%v)", path)
+	defer log.Infof(2, "END readTaggedEntryLink(%v)", path)
 
 	name := path[len(path)-1]