Skip to content

Commit 8889a74

Browse files
committed
Resolved #3
1 parent e16e388 commit 8889a74

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ COMMAND_LOG="./var/log/command.log"
2323
## The triggers.json file.
2424
This file is the bread and butter of your configuration. It is a .json file that contains a list of objects that define how the server should handle your requests to certain end-points. We have enclosed a `triggers.example.json` to give you an idea of how you could set your configuration up. Here it is below:
2525

26-
```
26+
```json
2727
[
2828
{
2929
"name":"asset_position_update",

triggers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ func processTrigger(trigger Trigger, processNow bool){
113113
return;
114114
}
115115

116-
time.AfterFunc(gDuration, func(){ processTrigger(trigger, false)});
116+
time.AfterFunc(gDuration, func(){ processTrigger(trigger, true)});
117117
}
118118

119119

120120
func validateTrigger(trigger Trigger) bool{
121-
// TODO: Implement this function.
121+
// TODO: Implement this function. See issue #2.
122122
return true;
123123
}

utils.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"log"
55
"os"
66
"github.com/joho/godotenv"
7-
8-
// "strconv"
97
)
108

119
const (
@@ -73,6 +71,7 @@ func outputTriggers(triggers []Trigger){
7371
* output is only available when --debugMode=true is set.
7472
*/
7573
func logText(sToLog string, err error) bool {
74+
// If we're in debug mode, we should output the errors to the running terminal.
7675
if debugMode {
7776
if err != nil {
7877
print(redColor + sToLog + "\n" + err.Error() + resetColor + "\n")
@@ -81,24 +80,29 @@ func logText(sToLog string, err error) bool {
8180
}
8281
}
8382

83+
// If it's an error, write to the error log.
8484
var logFile string
8585
if err != nil {
8686
logFile = errorLog
8787
} else {
8888
logFile = commandLog
8989
}
9090

91+
// Attempt to open the log file.
9192
file, fErr := os.OpenFile(logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
9293
if fErr != nil {
9394
log.Printf("ERROR: Could not write to log file: %v", fErr)
9495
return false
9596
}
9697
defer file.Close()
9798

99+
// Write sToLog to the log file.
98100
logger := log.New(file, "", log.LstdFlags)
99101
logger.Println(sToLog)
100102
if(err != nil){
101103
logger.Println(err.Error());
102104
}
105+
106+
// If we've made it this far, just return true.
103107
return true
104108
}

0 commit comments

Comments
 (0)