@@ -27,6 +27,7 @@ class CompilerHandler
27
27
private $ utility ;
28
28
private $ compiler_logger ;
29
29
private $ object_directory ;
30
+ private $ logger_id ;
30
31
31
32
function __construct (PreprocessingHandler $ preprocHandl , PostprocessingHandler $ postprocHandl , UtilityHandler $ utilHandl , Logger $ logger , $ objdir )
32
33
{
@@ -116,10 +117,18 @@ function main($request, $compiler_config)
116
117
117
118
// Log the names of the project files and the libraries used in it.
118
119
if ($ format != "autocomplete " ) {
120
+ $ user_id = "" ;
121
+ $ sketch_id = "" ;
119
122
$ req_elements = array ();
120
123
$ req_elements [] = "Files: " ;
121
124
foreach ($ request ["files " ] as $ file ) {
122
125
$ req_elements [] = $ file ["filename " ];
126
+ if (strpos ($ file ["filename " ], ".txt " ) !== false ) {
127
+ if (strpos ($ file ["filename " ], "user_ " ) !== false )
128
+ $ user_id = str_replace (".txt " , "" , str_replace ("user_ " , "" , $ file ["filename " ]));
129
+ else
130
+ $ sketch_id = str_replace (".txt " , "" , $ file ["filename " ]);
131
+ }
123
132
}
124
133
125
134
if ($ request ["libraries " ]) {
@@ -130,9 +139,11 @@ function main($request, $compiler_config)
130
139
}
131
140
}
132
141
133
- $ this ->compiler_logger ->addInfo ($ compiler_config ["compiler_dir " ] . " - " . implode (" " , $ req_elements ));
142
+ $ this ->logger_id = microtime (true ) . "_ " . substr ($ compiler_config ['compiler_dir ' ], -6 ) . "_user: $ user_id " . "_project: $ sketch_id " ;
143
+
144
+ $ this ->compiler_logger ->addInfo ($ this ->logger_id . " - " . implode (" " , $ req_elements ));
134
145
if ($ ARCHIVE_OPTION === true )
135
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - " . "Archive file: $ ARCHIVE_PATH " );
146
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - " . "Archive file: $ ARCHIVE_PATH " );
136
147
}
137
148
138
149
// Step 4: Syntax-check and compile source files.
@@ -344,7 +355,7 @@ function main($request, $compiler_config)
344
355
if ($ ret_link ){
345
356
346
357
// Log the fact that an error occurred during linking
347
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - An error occurred during linking: " . json_encode (implode ("\n" , $ output )));
358
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - An error occurred during linking: " . json_encode (implode ("\n" , $ output )));
348
359
349
360
$ returner = array (
350
361
"success " => false ,
@@ -659,40 +670,40 @@ private function doCompile($compiler_config, &$files, $dir, $CC, $CFLAGS, $CPP,
659
670
* and if significant differences are detected, return a modified version of the clang output.
660
671
*/
661
672
$ clangElements = $ this ->getClangErrorFileList ($ output );
662
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reported files: " . implode (" | " , array_keys ($ clangElements )));
673
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reported files: " . implode (" | " , array_keys ($ clangElements )));
663
674
$ gccElements = $ this ->getGccErrorFileList ($ avr_output );
664
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Gcc reported files: " . implode (" | " , array_keys ($ gccElements )));
675
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Gcc reported files: " . implode (" | " , array_keys ($ gccElements )));
665
676
666
677
if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements ))) {
667
678
668
679
$ resp ["old_message " ] = $ output ;
669
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Mismatch between clang and gcc output found. " );
680
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Mismatch between clang and gcc output found. " );
670
681
671
682
$ next_clang_output = $ this ->cleanUpClangOutput ($ output , $ compiler_config , "asm " );
672
683
673
684
$ clangElements = $ this ->getClangErrorFileList ($ next_clang_output );
674
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reported files after removing asm: " . implode (" | " , array_keys ($ clangElements )));
685
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reported files after removing asm: " . implode (" | " , array_keys ($ clangElements )));
675
686
676
687
if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements ))) {
677
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Mismatch between clang and gcc output found after removing assembly messages. " );
688
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Mismatch between clang and gcc output found after removing assembly messages. " );
678
689
$ final_clang_output = $ this ->cleanUpClangOutput ($ next_clang_output , $ compiler_config , "non_asm " );
679
690
680
691
$ clangElements = $ this ->getClangErrorFileList ($ final_clang_output );
681
692
if (array_diff (array_keys ($ clangElements ), array_keys ($ gccElements ))) {
682
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Mismatch between clang and gcc output found after removing assembly/library/core messages. " );
693
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Mismatch between clang and gcc output found after removing assembly/library/core messages. " );
683
694
}else {
684
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang and gcc issue solved. Both report same files with errors. " );
695
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang and gcc issue solved. Both report same files with errors. " );
685
696
}
686
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Gcc output: " . json_encode ($ avr_output ));
687
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang initial output: " . json_encode ($ output ));
688
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reformated output: " . json_encode ($ final_clang_output ));
697
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Gcc output: " . json_encode ($ avr_output ));
698
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang initial output: " . json_encode ($ output ));
699
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reformated output: " . json_encode ($ final_clang_output ));
689
700
$ final_clang_output = $ this ->pathRemover ($ final_clang_output , $ compiler_config );
690
701
$ resp ["message " ] = $ final_clang_output ;
691
702
return $ resp ;
692
703
}else {
693
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Gcc output: " . json_encode ($ avr_output ));
694
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang initial output: " . json_encode ($ output ));
695
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reformated output: " . json_encode ($ next_clang_output ));
704
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Gcc output: " . json_encode ($ avr_output ));
705
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang initial output: " . json_encode ($ output ));
706
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reformated output: " . json_encode ($ next_clang_output ));
696
707
$ next_clang_output = $ this ->pathRemover ($ next_clang_output , $ compiler_config );
697
708
$ resp ["message " ] = $ next_clang_output ;
698
709
return $ resp ;
@@ -1158,18 +1169,18 @@ private function cleanUpClangOutput ($clang_output, $compiler_config, $option) {
1158
1169
|| strpos ($ body , "in asm " ) !== false ))) {
1159
1170
1160
1171
if (preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header ) && $ libFound === false && $ option != "asm " ) {
1161
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports library issue. " );
1172
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reports library issue. " );
1162
1173
$ libFound = true ;
1163
1174
}
1164
1175
if ((strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) !== false
1165
1176
|| (array_key_exists ("external_core_files " , $ compiler_config )
1166
1177
&& strpos ($ header , $ compiler_config ["external_core_files " ]) !== false ))
1167
1178
&& $ coreFound === false && $ option != "asm " ) {
1168
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports core issue. " );
1179
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reports core issue. " );
1169
1180
$ coreFound = true ;
1170
1181
}
1171
1182
if ((strpos ($ header , "in asm " ) !== false || strpos ($ body , "in asm " ) !== false ) && $ asmFound === false && $ option == "asm " ) {
1172
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports assembly issue. " );
1183
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reports assembly issue. " );
1173
1184
$ asmFound = true ;
1174
1185
}
1175
1186
$ header = "" ;
@@ -1212,16 +1223,16 @@ private function cleanUpClangOutput ($clang_output, $compiler_config, $option) {
1212
1223
}
1213
1224
}else {
1214
1225
if (preg_match ('/(\/compiler\.\w+\/libraries\/)/ ' , $ header ) && $ libFound === false && $ option != "asm " ) {
1215
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports library issue. " );
1226
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reports library issue. " );
1216
1227
}
1217
1228
if ((strpos ($ header , $ compiler_config ["arduino_cores_dir " ]) !== false
1218
1229
|| (array_key_exists ("external_core_files " , $ compiler_config )
1219
1230
&& strpos ($ header , $ compiler_config ["external_core_files " ]) !== false ))
1220
1231
&& $ coreFound === false && $ option != "asm " ) {
1221
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports core issue. " );
1232
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reports core issue. " );
1222
1233
}
1223
1234
if ((strpos ($ header , "in asm " ) !== false || strpos ($ body , "in asm " ) !== false ) && $ asmFound === false && $ option == "asm " ) {
1224
- $ this ->compiler_logger ->addInfo ($ compiler_config [ " compiler_dir " ] . " - Clang reports assembly issue. " );
1235
+ $ this ->compiler_logger ->addInfo ($ this -> logger_id . " - Clang reports assembly issue. " );
1225
1236
}
1226
1237
}
1227
1238
}
0 commit comments