OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "net/test/test_server.h" | 12 #include "net/test/test_server.h" |
12 | 13 |
13 static void PrintUsage() { | 14 static void PrintUsage() { |
14 printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n"); | 15 printf("run_testserver --doc-root=relpath [--http|--https|--ftp|--sync]\n"); |
15 printf("(NOTE: relpath should be relative to the 'src' directory)\n"); | 16 printf("(NOTE: relpath should be relative to the 'src' directory)\n"); |
16 } | 17 } |
17 | 18 |
18 int main(int argc, const char* argv[]) { | 19 int main(int argc, const char* argv[]) { |
19 base::AtExitManager at_exit_manager; | 20 base::AtExitManager at_exit_manager; |
20 MessageLoopForIO message_loop; | 21 MessageLoopForIO message_loop; |
21 | 22 |
22 // Process command line | 23 // Process command line |
23 CommandLine::Init(argc, argv); | 24 CommandLine::Init(argc, argv); |
24 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 25 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
25 | 26 |
27 (void)logging::InitLogging(FILE_PATH_LITERAL("testserver.log"), | |
cbentzel
2010/11/17 22:32:50
Do this in a separate CL?
| |
28 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | |
29 logging::LOCK_LOG_FILE, | |
30 logging::APPEND_TO_OLD_LOG_FILE); | |
31 | |
26 if (command_line->GetSwitchCount() == 0 || | 32 if (command_line->GetSwitchCount() == 0 || |
27 command_line->HasSwitch("help")) { | 33 command_line->HasSwitch("help")) { |
28 PrintUsage(); | 34 PrintUsage(); |
29 return -1; | 35 return -1; |
30 } | 36 } |
31 | 37 |
32 net::TestServer::Type server_type(net::TestServer::TYPE_HTTP); | 38 net::TestServer::Type server_type(net::TestServer::TYPE_HTTP); |
33 if (command_line->HasSwitch("https")) { | 39 if (command_line->HasSwitch("https")) { |
34 server_type = net::TestServer::TYPE_HTTPS; | 40 server_type = net::TestServer::TYPE_HTTPS; |
35 } else if (command_line->HasSwitch("ftp")) { | 41 } else if (command_line->HasSwitch("ftp")) { |
(...skipping 14 matching lines...) Expand all Loading... | |
50 printf("Error: failed to start test server. Exiting.\n"); | 56 printf("Error: failed to start test server. Exiting.\n"); |
51 return -1; | 57 return -1; |
52 } | 58 } |
53 | 59 |
54 printf("testserver running at %s (type ctrl+c to exit)\n", | 60 printf("testserver running at %s (type ctrl+c to exit)\n", |
55 test_server.host_port_pair().ToString().c_str()); | 61 test_server.host_port_pair().ToString().c_str()); |
56 | 62 |
57 message_loop.Run(); | 63 message_loop.Run(); |
58 return 0; | 64 return 0; |
59 } | 65 } |
OLD | NEW |