Skip to content

Commit 4e7cd4f

Browse files
committed
Remove newline from log lines.
So we don't send the new lines in the callbacks.
1 parent 3ccbf62 commit 4e7cd4f

25 files changed

+151
-149
lines changed

config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ bool proxy_config_global_init(void) {
125125
g_proxy_config.proxy_config_i = proxy_config_win_get_interface();
126126
#endif
127127
if (!g_proxy_config.proxy_config_i) {
128-
LOG_ERROR("No config interface found\n");
128+
log_error("No config interface found");
129129
return false;
130130
}
131131
g_proxy_config.ref_count++;

execute_duktape.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ bool proxy_execute_duktape_get_proxies_for_url(void *ctx, const char *script, co
8888

8989
// Load Mozilla's JavaScript PAC utilities to help process PAC files
9090
if (duk_peval_string(duk_ctx, MOZILLA_PAC_JAVASCRIPT) != 0) {
91-
LOG_ERROR("Failed to parse Mozilla PAC JavaScript\n");
91+
log_error("Failed to parse Mozilla PAC JavaScript");
9292
duk_pop(duk_ctx);
9393
return false;
9494
}
9595

9696
// Evaluate the PAC script
9797
if (duk_peval_string(duk_ctx, script) != 0) {
98-
LOG_ERROR("Error evaluating PAC script: %s\n", duk_safe_to_string(duk_ctx, -1));
98+
log_error("Error evaluating PAC script: %s", duk_safe_to_string(duk_ctx, -1));
9999
duk_pop(duk_ctx);
100100
return false;
101101
}
@@ -105,7 +105,7 @@ bool proxy_execute_duktape_get_proxies_for_url(void *ctx, const char *script, co
105105
duk_push_global_object(duk_ctx);
106106
duk_get_prop_string(duk_ctx, -1, "FindProxyForURL");
107107
if (!duk_is_function(duk_ctx, -1)) {
108-
LOG_ERROR("FindProxyForURL is not a function\n");
108+
log_error("FindProxyForURL is not a function");
109109
duk_pop_2(duk_ctx);
110110
return false;
111111
}
@@ -117,7 +117,7 @@ bool proxy_execute_duktape_get_proxies_for_url(void *ctx, const char *script, co
117117

118118
// Execute the call to FindProxyForURL
119119
if (duk_pcall(duk_ctx, 2) != 0) {
120-
LOG_ERROR("Error calling FindProxyForURL: %s\n", duk_safe_to_string(duk_ctx, -1));
120+
log_error("Error calling FindProxyForURL: %s", duk_safe_to_string(duk_ctx, -1));
121121
duk_pop_2(duk_ctx);
122122
return false;
123123
}

execute_jsc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void js_print_exception(JSCContext *context, JSCException *exception) {
6666
return;
6767
}
6868

69-
LOG_ERROR("Unable to print exception object\n");
69+
log_error("Unable to print exception object");
7070
}
7171

7272
static char *proxy_execute_jsc_dns_resolve(const char *host) {
@@ -105,7 +105,7 @@ bool proxy_execute_jsc_get_proxies_for_url(void *ctx, const char *script, const
105105

106106
global = g_proxy_execute_jsc.jsc_context_new();
107107
if (!global) {
108-
LOG_ERROR("Failed to create global JS context\n");
108+
log_error("Failed to create global JS context");
109109
goto jscgtk_execute_cleanup;
110110
}
111111

@@ -128,7 +128,7 @@ bool proxy_execute_jsc_get_proxies_for_url(void *ctx, const char *script, const
128128
functions[i].param_count, G_TYPE_STRING);
129129

130130
if (!functions[i].value) {
131-
LOG_ERROR("Unable to hook native function for %s\n", functions[i].name);
131+
log_error("Unable to hook native function for %s", functions[i].name);
132132
goto jscgtk_execute_cleanup;
133133
}
134134

@@ -139,7 +139,7 @@ bool proxy_execute_jsc_get_proxies_for_url(void *ctx, const char *script, const
139139
result = g_proxy_execute_jsc.jsc_context_evaluate(global, MOZILLA_PAC_JAVASCRIPT, -1);
140140
exception = g_proxy_execute_jsc.jsc_context_get_exception(global);
141141
if (exception) {
142-
LOG_ERROR("Unable to execute Mozilla's JavaScript PAC utilities\n");
142+
log_error("Unable to execute Mozilla's JavaScript PAC utilities");
143143
js_print_exception(global, exception);
144144
goto jscgtk_execute_cleanup;
145145
}
@@ -150,7 +150,7 @@ bool proxy_execute_jsc_get_proxies_for_url(void *ctx, const char *script, const
150150
result = g_proxy_execute_jsc.jsc_context_evaluate(global, script, -1);
151151
exception = g_proxy_execute_jsc.jsc_context_get_exception(global);
152152
if (exception) {
153-
LOG_ERROR("Unable to execute PAC script\n");
153+
log_error("Unable to execute PAC script");
154154
js_print_exception(global, exception);
155155
goto jscgtk_execute_cleanup;
156156
}
@@ -166,13 +166,13 @@ bool proxy_execute_jsc_get_proxies_for_url(void *ctx, const char *script, const
166166
result = g_proxy_execute_jsc.jsc_context_evaluate(global, find_proxy, -1);
167167
exception = g_proxy_execute_jsc.jsc_context_get_exception(global);
168168
if (exception) {
169-
LOG_ERROR("Unable to execute FindProxyForURL\n");
169+
log_error("Unable to execute FindProxyForURL");
170170
js_print_exception(global, exception);
171171
goto jscgtk_execute_cleanup;
172172
}
173173

174174
if (!g_proxy_execute_jsc.jsc_value_is_string(result)) {
175-
LOG_ERROR("Incorrect return type from FindProxyForURL\n");
175+
log_error("Incorrect return type from FindProxyForURL");
176176
goto jscgtk_execute_cleanup;
177177
}
178178

execute_jscore.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static void js_print_exception(JSContextRef ctx, JSValueRef exception) {
126126
}
127127

128128
if (!printed) {
129-
LOG_ERROR("Unable to print unknown exception object\n");
129+
log_error("Unable to print unknown exception object");
130130
return;
131131
}
132132
}
@@ -234,7 +234,7 @@ bool proxy_execute_register_function(void *ctx, JSGlobalContextRef global, const
234234
JSObjectRef function = g_proxy_execute_jscore.JSObjectMakeFunctionWithCallback(global, name_string, callback);
235235
if (!function) {
236236
g_proxy_execute_jscore.JSStringRelease(name_string);
237-
LOG_ERROR("Unable to hook native function for %s\n", name);
237+
log_error("Unable to hook native function for %s", name);
238238
return false;
239239
}
240240

@@ -262,7 +262,7 @@ bool proxy_execute_jscore_get_proxies_for_url(void *ctx, const char *script, con
262262

263263
global = g_proxy_execute_jscore.JSGlobalContextCreate(NULL);
264264
if (!global) {
265-
LOG_ERROR("Failed to create global JS context\n");
265+
log_error("Failed to create global JS context");
266266
goto jscoregtk_execute_cleanup;
267267
}
268268

@@ -279,13 +279,13 @@ bool proxy_execute_jscore_get_proxies_for_url(void *ctx, const char *script, con
279279
// Load Mozilla's JavaScript PAC utilities to help process PAC files
280280
utils_javascript = g_proxy_execute_jscore.JSStringCreateWithUTF8CString(MOZILLA_PAC_JAVASCRIPT);
281281
if (!utils_javascript) {
282-
LOG_ERROR("Unable to load Mozilla's JavaScript PAC utilities\n");
282+
log_error("Unable to load Mozilla's JavaScript PAC utilities");
283283
goto jscoregtk_execute_cleanup;
284284
}
285285
g_proxy_execute_jscore.JSEvaluateScript(global, utils_javascript, NULL, NULL, 1, &exception);
286286
g_proxy_execute_jscore.JSStringRelease(utils_javascript);
287287
if (exception) {
288-
LOG_ERROR("Unable to execute Mozilla's JavaScript PAC utilities\n");
288+
log_error("Unable to execute Mozilla's JavaScript PAC utilities");
289289
js_print_exception(global, exception);
290290
goto jscoregtk_execute_cleanup;
291291
}
@@ -295,7 +295,7 @@ bool proxy_execute_jscore_get_proxies_for_url(void *ctx, const char *script, con
295295
g_proxy_execute_jscore.JSEvaluateScript(global, script_string, NULL, NULL, 1, &exception);
296296
g_proxy_execute_jscore.JSStringRelease(script_string);
297297
if (exception) {
298-
LOG_ERROR("Unable to execute PAC script\n");
298+
log_error("Unable to execute PAC script");
299299
js_print_exception(global, exception);
300300
goto jscoregtk_execute_cleanup;
301301
}
@@ -312,13 +312,13 @@ bool proxy_execute_jscore_get_proxies_for_url(void *ctx, const char *script, con
312312
proxy_value = g_proxy_execute_jscore.JSEvaluateScript(global, find_proxy_string, NULL, NULL, 1, &exception);
313313
g_proxy_execute_jscore.JSStringRelease(find_proxy_string);
314314
if (exception) {
315-
LOG_ERROR("Unable to execute FindProxyForURL\n");
315+
log_error("Unable to execute FindProxyForURL");
316316
js_print_exception(global, exception);
317317
goto jscoregtk_execute_cleanup;
318318
}
319319

320320
if (!g_proxy_execute_jscore.JSValueIsString(global, proxy_value)) {
321-
LOG_ERROR("Incorrect return type from FindProxyForURL\n");
321+
log_error("Incorrect return type from FindProxyForURL");
322322
goto jscoregtk_execute_cleanup;
323323
}
324324

execute_wsh.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,46 +52,46 @@ static bool script_engine_create(proxy_execute_wsh_s *proxy_execute_wsh) {
5252

5353
HRESULT result = CLSIDFromProgID(L"JavaScript", &lang_clsid);
5454
if (FAILED(result)) {
55-
LOG_ERROR("Failed to find JavaScript CLSID: (%08lx)\n", result);
55+
log_error("Failed to find JavaScript CLSID: (%08lx)", result);
5656
return false;
5757
}
5858

5959
result = CoCreateInstance(&lang_clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IActiveScript,
6060
(void **)&proxy_execute_wsh->active_script);
6161
if (FAILED(result)) {
62-
LOG_ERROR("Failed to create active script instance (%08lx)\n", result);
62+
log_error("Failed to create active script instance (%08lx)", result);
6363
return false;
6464
}
6565

6666
result = IActiveScript_QueryInterface(proxy_execute_wsh->active_script, &IID_IActiveScriptParse,
6767
(void **)&proxy_execute_wsh->active_script_parse);
6868
if (FAILED(result)) {
69-
LOG_ERROR("Failed to create active script parse instance (%08lx)\n", result);
69+
log_error("Failed to create active script parse instance (%08lx)", result);
7070
return false;
7171
}
7272

7373
result = IActiveScript_SetScriptSite(proxy_execute_wsh->active_script, &proxy_execute_wsh->active_script_site.site);
7474
if (FAILED(result)) {
75-
LOG_ERROR("Failed to set script site for active script (%08lx)\n", result);
75+
log_error("Failed to set script site for active script (%08lx)", result);
7676
return false;
7777
}
7878

7979
result = IActiveScriptParse_InitNew(proxy_execute_wsh->active_script_parse);
8080
if (FAILED(result)) {
81-
LOG_ERROR("Failed to initialize active script parse (%08lx)\n", result);
81+
log_error("Failed to initialize active script parse (%08lx)", result);
8282
return false;
8383
}
8484

8585
result = IActiveScript_AddNamedItem(proxy_execute_wsh->active_script, WSH_SCRIPT_NAME,
8686
SCRIPTITEM_GLOBALMEMBERS | SCRIPTITEM_ISVISIBLE);
8787
if (FAILED(result)) {
88-
LOG_ERROR("Failed to add named item to active script (%08lx)\n", result);
88+
log_error("Failed to add named item to active script (%08lx)", result);
8989
return false;
9090
}
9191

9292
result = IActiveScript_SetScriptState(proxy_execute_wsh->active_script, SCRIPTSTATE_STARTED);
9393
if (FAILED(result)) {
94-
LOG_ERROR("Failed to set script state to started (%08lx)\n", result);
94+
log_error("Failed to set script state to started (%08lx)", result);
9595
return false;
9696
}
9797

@@ -114,7 +114,7 @@ static bool script_engine_parse_text(proxy_execute_wsh_s *proxy_execute_wsh, con
114114
SysFreeString(script_bstr);
115115

116116
if (FAILED(result)) {
117-
LOG_ERROR("Failed to parse script text (%08lx)\n", result);
117+
log_error("Failed to parse script text (%08lx)", result);
118118
return false;
119119
}
120120

@@ -128,15 +128,15 @@ static bool script_engine_find_proxy_for_url(proxy_execute_wsh_s *proxy_execute_
128128

129129
HRESULT result = IActiveScript_GetScriptDispatch(proxy_execute_wsh->active_script, NULL, &dispatch);
130130
if (FAILED(result)) {
131-
LOG_ERROR("Failed to get script dispatch (%08lx)\n", result);
131+
log_error("Failed to get script dispatch (%08lx)", result);
132132
return false;
133133
}
134134

135135
// Get the id for the FindProxyForURL function to call
136136
LPOLESTR find_proxy_for_url = OLESTR("FindProxyForURL");
137137
result = IDispatch_GetIDsOfNames(dispatch, &IID_NULL, &find_proxy_for_url, 1, LOCALE_NEUTRAL, &disp_id);
138138
if (FAILED(result)) {
139-
LOG_ERROR("Failed to get ID of names (%08lx)\n", result);
139+
log_error("Failed to get ID of names (%08lx)", result);
140140
goto script_engine_execute_cleanup;
141141
}
142142

@@ -158,14 +158,14 @@ static bool script_engine_find_proxy_for_url(proxy_execute_wsh_s *proxy_execute_
158158
// Create VARIANTARG for the host parameter
159159
char *host = get_url_host(url);
160160
if (!host) {
161-
LOG_ERROR("Failed to get host from url\n");
161+
log_error("Failed to get host from url");
162162
goto script_engine_execute_cleanup;
163163
}
164164

165165
wchar_t *host_wchar = utf8_dup_to_wchar(host);
166166
free(host);
167167
if (!host_wchar) {
168-
LOG_ERROR("Failed to convert host to wchar\n");
168+
log_error("Failed to convert host to wchar");
169169
goto script_engine_execute_cleanup;
170170
}
171171

@@ -181,13 +181,13 @@ static bool script_engine_find_proxy_for_url(proxy_execute_wsh_s *proxy_execute_
181181
result = IDispatch_Invoke(dispatch, disp_id, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &params, &result_ptr, NULL,
182182
NULL);
183183
if (FAILED(result)) {
184-
LOG_ERROR("Failed to invoke script (%08lx)\n", result);
184+
log_error("Failed to invoke script (%08lx)", result);
185185
goto script_engine_execute_cleanup;
186186
}
187187

188188
// Return the result of the FindProxyForURL function
189189
if (result_ptr.vt != VT_BSTR) {
190-
LOG_ERROR("Invalid result type returned from script (%d)\n", result_ptr.vt);
190+
log_error("Invalid result type returned from script (%d)", result_ptr.vt);
191191
goto script_engine_execute_cleanup;
192192
}
193193

@@ -211,21 +211,21 @@ static bool script_engine_delete(proxy_execute_wsh_s *proxy_execute_wsh) {
211211
if (proxy_execute_wsh->active_script) {
212212
HRESULT result = IActiveScript_Close(proxy_execute_wsh->active_script);
213213
if (FAILED(result)) {
214-
LOG_ERROR("Failed to close active script (%08lx)\n", result);
214+
log_error("Failed to close active script (%08lx)", result);
215215
return false;
216216
}
217217
}
218218
if (proxy_execute_wsh->active_script_parse) {
219219
HRESULT result = IActiveScriptParse_Release(proxy_execute_wsh->active_script_parse);
220220
if (FAILED(result)) {
221-
LOG_ERROR("Failed to release active script parse (%08lx)\n", result);
221+
log_error("Failed to release active script parse (%08lx)", result);
222222
return false;
223223
}
224224
}
225225
if (proxy_execute_wsh->active_script) {
226226
HRESULT result = IActiveScript_Release(proxy_execute_wsh->active_script);
227227
if (FAILED(result)) {
228-
LOG_ERROR("Failed to release active script (%08lx)\n", result);
228+
log_error("Failed to release active script (%08lx)", result);
229229
return false;
230230
}
231231
}
@@ -245,17 +245,17 @@ bool proxy_execute_wsh_get_proxies_for_url(void *ctx, const char *script, const
245245
return false;
246246

247247
if (!script_engine_parse_text(proxy_execute_wsh, MOZILLA_PAC_JAVASCRIPT)) {
248-
LOG_ERROR("Failed to parse Mozilla PAC JavaScript\n");
248+
log_error("Failed to parse Mozilla PAC JavaScript");
249249
goto execute_wsh_cleanup;
250250
}
251251

252252
if (!script_engine_parse_text(proxy_execute_wsh, script)) {
253-
LOG_ERROR("Failed to parse PAC script\n");
253+
log_error("Failed to parse PAC script");
254254
goto execute_wsh_cleanup;
255255
}
256256

257257
if (!script_engine_find_proxy_for_url(proxy_execute_wsh, url)) {
258-
LOG_ERROR("Failed to execute script\n");
258+
log_error("Failed to execute script");
259259
goto execute_wsh_cleanup;
260260
}
261261

execute_wsh_site.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static HRESULT STDMETHODCALLTYPE active_script_site_on_script_error(IActiveScrip
9999
// Print exception information to log
100100
HRESULT result = IActiveScriptError_GetExceptionInfo(error, &excep_info);
101101
if (FAILED(result)) {
102-
LOG_ERROR("Failed to get active script error (0x%08lx)\n", result);
102+
log_error("Failed to get active script error (0x%08lx)", result);
103103
return S_OK;
104104
}
105105

fetch_curl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ static size_t fetch_write_script(void *contents, size_t size, size_t nscriptb, v
2222
size_t total_size = script->size + new_size;
2323

2424
if (total_size > SCRIPT_MAX) {
25-
LOG_ERROR("Script size exceeds maximum (%" PRId64 ")\n", (int64_t)total_size);
25+
log_error("Script size exceeds maximum (%" PRId64 ")", (int64_t)total_size);
2626
return 0;
2727
}
2828

2929
char *ptr = realloc(script->buffer, total_size + 1);
3030
if (!ptr) {
31-
LOG_ERROR("Unable to allocate memory for %s (%" PRId32 ")\n", "script", errno);
31+
log_error("Unable to allocate memory for %s (%" PRId32 ")", "script", errno);
3232
return 0;
3333
}
3434

@@ -46,7 +46,7 @@ char *fetch_get(const char *url, int32_t *error) {
4646

4747
CURL *curl_handle = curl_easy_init();
4848
if (!curl_handle) {
49-
LOG_ERROR("Unable to initialize curl handle\n");
49+
log_error("Unable to initialize curl handle");
5050
return NULL;
5151
}
5252

@@ -83,7 +83,7 @@ char *fetch_get(const char *url, int32_t *error) {
8383
bool fetch_global_init(void) {
8484
CURLcode res = curl_global_init(CURL_GLOBAL_ALL);
8585
if (res != CURLE_OK) {
86-
LOG_ERROR("Unable to initialize curl\n");
86+
log_error("Unable to initialize curl");
8787
return false;
8888
}
8989
return true;

0 commit comments

Comments
 (0)