Example #1
0
func NewDataLogger(dirPath string, name string, truncateMode int8, levelMode int8, cacheLineCount int) (*DataLogger, error) {
	this := DataLogger{}
	this.dirPath = fmt.Sprintf("%s/%s", dirPath, name)
	this.name = name
	this.truncateMode = truncateMode
	this.levelMode = levelMode
	this.levelString = levelModeToString(levelMode)
	this.cacheLineCount = cacheLineCount

	toolkit.EnsureDirExists(this.dirPath)
	this.writingName = this.getFileName()
	this.lines = make(chan string, 1000000)
	this.quit = make(chan bool, 1)
	this.lock = new(sync.Mutex)
	if this.truncateMode != TruncateImmediately {
		this.autoFlush()
	}
	return &this, nil
}
Example #2
0
func (this *FileCache) Set(category, key string, data []byte) error {
	fullpath := this.FullPath(category, key)
	toolkit.EnsureDirExists(toolkit.ParentPath(fullpath))

	return toolkit.WriteAll(data, fullpath)
}
Example #3
0
func getFileCache() *FileCache {
	toolkit.EnsureDirExists("/tmp/figo_cache")
	return NewFileCache("/tmp/figo_cache")
}