Contains all of the functions necessary for logging to the console, and logging to the system-specified log file. Some of the logic here is duplicated from the Haystacks repo, but kept super basic intentionally. Logging from the plugin will remain hard-coded, because the data isn't loaded, and by the time it is loaded its already useless to log. So uncomment the lines in the plugin code if you need to log from the plugin, and leave them commented out if you don't need to log. This is setup here so that the logs can be added to the application level log file, especially to include data, as the data can be too much and will easily overflow the console buffer.
- Copyright:
- Copyright © 2023-… by Seth Hollingsead. All rights reserved
- Source:
Requires
- module:plugin.constants
- module:pluginData
- @haystacks/constants
- moment
- fs
- path
Methods
(inner) appendMessageToFile(message) → {void}
Opens a file and appends a message to the file, then closes the file.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string | The message that should be appended to the log file. |
- Source:
Returns:
- Type
- void
(inner) consoleLog(classPath, message) → {void}
Logs out to the console, and to the same current Haystacks-application log file.
Parameters:
| Name | Type | Description |
|---|---|---|
classPath |
string | The class pass from which this console log function was called from. |
message |
string | The message and/or data that should be logged to the console, and the log file. |
- Source:
Returns:
- Type
- void
(inner) getLogFileNameAndPath(haystacksConfigData) → {string}
Determines, using the Haystacks configuration settings data passed as input to the plugin entry-point, what the log file name and path should be.
Parameters:
| Name | Type | Description |
|---|---|---|
haystacksConfigData |
object | A JSON object that contains all of the configuration data including the log file name and path. |
- Source:
Returns:
The full path and file name for the log file.
- Type
- string
(inner) getNowMoment(formatString) → {string}
Returns a time stamp string formatted according to the input formatting string.
Parameters:
| Name | Type | Description |
|---|---|---|
formatString |
string | The formatting string, that tells moment in what format to return the value for the day, month, year, hour, minute, second, and millisecond. |
- Source:
Returns:
A time stamp string that has been formatted according to the input format.
- Type
- string