|
67 | 67 | signatureKey = iniConf.String("signatureKey", "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvc0yZr1yUSen7qmE3cxF\nIE12rCksDnqR+Hp7o0nGi9123eCSFcJ7CkIRC8F+8JMhgI3zNqn4cUEn47I3RKD1\nZChPUCMiJCvbLbloxfdJrUi7gcSgUXrlKQStOKF5Iz7xv1M4XOP3JtjXLGo3EnJ1\npFgdWTOyoSrA8/w1rck4c/ISXZSinVAggPxmLwVEAAln6Itj6giIZHKvA2fL2o8z\nCeK057Lu8X6u2CG8tRWSQzVoKIQw/PKK6CNXCAy8vo4EkXudRutnEYHEJlPkVgPn\n2qP06GI+I+9zKE37iqj0k1/wFaCVXHXIvn06YrmjQw6I0dDj/60Wvi500FuRVpn9\ntwIDAQAB\n-----END PUBLIC KEY-----", "Pem-encoded public key to verify signed commandlines")
|
68 | 68 | updateUrl = iniConf.String("updateUrl", "", "")
|
69 | 69 | verbose = iniConf.Bool("v", true, "show debug logging")
|
| 70 | + crashreport = iniConf.Bool("crashreport", false, "enable crashreport logging") |
70 | 71 | )
|
71 | 72 |
|
72 | 73 | // global clients
|
@@ -111,24 +112,6 @@ func main() {
|
111 | 112 | os.Exit(0)
|
112 | 113 | }
|
113 | 114 |
|
114 |
| - // save crashreport to file |
115 |
| - logFilename := "crashreport_" + time.Now().Format("20060102150405") + ".log" |
116 |
| - currDir, err := osext.ExecutableFolder() |
117 |
| - if err != nil { |
118 |
| - panic(err) |
119 |
| - } |
120 |
| - // handle logs directory creation |
121 |
| - logsDir := filepath.Join(currDir, "logs") |
122 |
| - if _, err := os.Stat(logsDir); os.IsNotExist(err) { |
123 |
| - os.Mkdir(logsDir, 0700) |
124 |
| - } |
125 |
| - logFile, err := os.OpenFile(filepath.Join(logsDir, logFilename), os.O_WRONLY|os.O_CREATE|os.O_SYNC|os.O_APPEND, 0644) |
126 |
| - if err != nil { |
127 |
| - log.Print("Cannot create file used for crash-report") |
128 |
| - } else { |
129 |
| - redirectStderr(logFile) |
130 |
| - } |
131 |
| - |
132 | 115 | // Launch main loop in a goroutine
|
133 | 116 | go loop()
|
134 | 117 |
|
@@ -306,6 +289,26 @@ func loop() {
|
306 | 289 | log.SetOutput(new(NullWriter)) //route all logging to nullwriter
|
307 | 290 | }
|
308 | 291 |
|
| 292 | + // save crashreport to file |
| 293 | + if *crashreport { |
| 294 | + logFilename := "crashreport_" + time.Now().Format("20060102150405") + ".log" |
| 295 | + currDir, err := osext.ExecutableFolder() |
| 296 | + if err != nil { |
| 297 | + panic(err) |
| 298 | + } |
| 299 | + // handle logs directory creation |
| 300 | + logsDir := filepath.Join(currDir, "logs") |
| 301 | + if _, err := os.Stat(logsDir); os.IsNotExist(err) { |
| 302 | + os.Mkdir(logsDir, 0700) |
| 303 | + } |
| 304 | + logFile, err := os.OpenFile(filepath.Join(logsDir, logFilename), os.O_WRONLY|os.O_CREATE|os.O_SYNC|os.O_APPEND, 0644) |
| 305 | + if err != nil { |
| 306 | + log.Print("Cannot create file used for crash-report") |
| 307 | + } else { |
| 308 | + redirectStderr(logFile) |
| 309 | + } |
| 310 | + } |
| 311 | + |
309 | 312 | // launch the hub routine which is the singleton for the websocket server
|
310 | 313 | go h.run()
|
311 | 314 | // launch our serial port routine
|
|
0 commit comments