## SuccessLog
thread-keeper
**Author**: The Harvard Library Innovation Lab
**License**: MIT
* [SuccessLog](#utils.module_SuccessLog)
* [.SuccessLog](#utils.module_SuccessLog.SuccessLog)
* [new exports.SuccessLog()](#new_utils.module_SuccessLog.SuccessLog_new)
* [.filepath](#utils.module_SuccessLog.SuccessLog+filepath) : string
* [.add(identifier, why, pdfBytes)](#utils.module_SuccessLog.SuccessLog+add)
* [.findHashInLogs(hash)](#utils.module_SuccessLog.SuccessLog+findHashInLogs) ⇒ boolean
* [.reset()](#utils.module_SuccessLog.SuccessLog+reset) ⇒ void
### SuccessLog.SuccessLog
Utility class for handling success logs. Keeps trace of the hashes of the PDFs that were generated.
**Kind**: static class of [SuccessLog
](#utils.module_SuccessLog)
* [.SuccessLog](#utils.module_SuccessLog.SuccessLog)
* [new exports.SuccessLog()](#new_utils.module_SuccessLog.SuccessLog_new)
* [.filepath](#utils.module_SuccessLog.SuccessLog+filepath) : string
* [.add(identifier, why, pdfBytes)](#utils.module_SuccessLog.SuccessLog+add)
* [.findHashInLogs(hash)](#utils.module_SuccessLog.SuccessLog+findHashInLogs) ⇒ boolean
* [.reset()](#utils.module_SuccessLog.SuccessLog+reset) ⇒ void
#### new exports.SuccessLog()
On init:
- Create log file if it doesn't exist
- Load hashes from file into `this.#hashes`.
#### successLog.filepath : string
Complete path to `success-log.json`.
**Kind**: instance property of [SuccessLog
](#utils.module_SuccessLog.SuccessLog)
#### successLog.add(identifier, why, pdfBytes)
Calculates hash of a PDF an:
- Creates a success log entry
- Updates `this.#hashes` (so it doesn't need to reload from file)
**Kind**: instance method of [SuccessLog
](#utils.module_SuccessLog.SuccessLog)
| Param | Type | Description |
| --- | --- | --- |
| identifier | string
| Can be an IP or access key |
| why | string
| Reason for creating this archive |
| pdfBytes | Buffer
| Used to store a SHA512 hash of the PDF that was delivered |
#### successLog.findHashInLogs(hash) ⇒ boolean
Checks whether or not a given hash is present in the logs.
**Kind**: instance method of [SuccessLog
](#utils.module_SuccessLog.SuccessLog)
| Param | Type |
| --- | --- |
| hash | string
|
#### successLog.reset() ⇒ void
Resets `success-log.json`.
Also clears `this.#hashes`.
**Kind**: instance method of [SuccessLog
](#utils.module_SuccessLog.SuccessLog)