Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe870cb

Browse files
committed
Fixed indentation.
1 parente214cf6 commitfe870cb

File tree

3 files changed

+101
-102
lines changed

3 files changed

+101
-102
lines changed

‎include/network/logging/logging.hpp‎

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,60 +6,60 @@
66

77
namespacenetwork {namespacelogging {
88

9-
classlog_record;
10-
11-
//using log_record_handler = std::function< void (const std::string&) >; // use this when VS can compile it...
12-
typedef std::function<void (const log_record&) > log_record_handler;
9+
classlog_record;
1310

14-
voidset_log_record_handler( log_record_handler handler );
15-
voidlog(const log_record& message );
16-
17-
namespacehandler
18-
{
19-
log_record_handlerget_std_log_handler();
20-
log_record_handlerget_default_log_handler();
21-
}
22-
23-
/** Helper to build a log record as a stream.*/
24-
classlog_record
25-
{
26-
public:
27-
log_record(){}// = default;
11+
//using log_record_handler = std::function< void (const std::string&) >; // use this when VS can compile it...
12+
typedef std::function<void (const log_record&) > log_record_handler;
2813

29-
// Implicit construction from string
30-
log_record(const std::string& message )
31-
{
32-
write( message );
33-
}
14+
voidset_log_record_handler( log_record_handler handler );
15+
voidlog(const log_record& message );
3416

35-
~log_record()
36-
{
37-
log( *this );
38-
}
39-
40-
template<typename TypeOfSomething >
41-
log_record&write(const TypeOfSomething& something )// THINK: use universal references?
42-
{
43-
m_text_stream << something;
44-
return *this;
45-
}
17+
namespacehandler
18+
{
19+
log_record_handlerget_std_log_handler();
20+
log_record_handlerget_default_log_handler();
21+
}
4622

47-
std::stringfull_message()const {return m_text_stream.str(); }
23+
/** Helper to build a log record as a stream.*/
24+
classlog_record
25+
{
26+
public:
27+
log_record(){}// = default;
4828

49-
private:
50-
// disable copy
51-
log_record(const log_record& );// = delete;
52-
log_record&operator=(const log_record& );// = delete;
29+
// Implicit construction from string
30+
log_record(const std::string& message )
31+
{
32+
write( message );
33+
}
5334

54-
std::ostringstream m_text_stream;// stream in which we build the message
55-
56-
};
57-
58-
template<typename TypeOfSomething >
59-
inline log_record&operator<<( log_record& log,const TypeOfSomething& something )// THINK: use universal references?
60-
{
61-
return log.write( something );
62-
}
35+
~log_record()
36+
{
37+
log( *this );
38+
}
39+
40+
template<typename TypeOfSomething >
41+
log_record&write(const TypeOfSomething& something )// THINK: use universal references?
42+
{
43+
m_text_stream << something;
44+
return *this;
45+
}
46+
47+
std::stringfull_message()const {return m_text_stream.str(); }
48+
49+
private:
50+
// disable copy
51+
log_record(const log_record& );// = delete;
52+
log_record&operator=(const log_record& );// = delete;
53+
54+
std::ostringstream m_text_stream;// stream in which we build the message
55+
56+
};
57+
58+
template<typename TypeOfSomething >
59+
inline log_record&operator<<( log_record& log,const TypeOfSomething& something )// THINK: use universal references?
60+
{
61+
return log.write( something );
62+
}
6363

6464
}}
6565

‎libs/network/src/CMakeLists.txt‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
2121
endif()
2222

2323
if( CPP-NETLIB_ALWAYS_LOGGING )
24-
add_definitions( /D NETWORK_ENABLE_LOGGING )
24+
add_definitions( /D NETWORK_ENABLE_LOGGING )
2525
endif()
2626

2727
if(NOT CPP-NETLIB_DISABLE_LOGGING )
28-
set( CPP-NETLIB_LOGGING_SRCS
29-
logging/logging.cpp
30-
)
31-
add_library(cppnetlib-logging ${CPP-NETLIB_LOGGING_SRCS})
32-
foreach (src_file ${CPP-NETLIB_LOGGING_SRCS})
33-
if (${CMAKE_CXX_COMPILER_ID}MATCHES GNU)
34-
set_source_files_properties(${src_file}
35-
PROPERTIESCOMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
36-
endif()
37-
endforeach(src_file)
38-
39-
# this library name is defined only if we created the target
40-
# if not then it will be empty
41-
set( CPP-NETLIB_LOGGING_LIB cppnetlib-logging )
42-
28+
set( CPP-NETLIB_LOGGING_SRCS
29+
logging/logging.cpp
30+
)
31+
add_library(cppnetlib-logging ${CPP-NETLIB_LOGGING_SRCS})
32+
foreach (src_file ${CPP-NETLIB_LOGGING_SRCS})
33+
if (${CMAKE_CXX_COMPILER_ID}MATCHES GNU)
34+
set_source_files_properties(${src_file}
35+
PROPERTIESCOMPILE_FLAGS ${CPP-NETLIB_CXXFLAGS})
36+
endif()
37+
endforeach(src_file)
38+
39+
# this library name is defined only if we created the target
40+
# if not then it will be empty
41+
set( CPP-NETLIB_LOGGING_LIB cppnetlib-logging )
42+
4343
endif()
4444

4545
set(CPP-NETLIB_URI_SRCS uri/uri.cpp uri/schemes.cpp uri/normalize.cpp)
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#ifdef NETWORK_NO_LIB
32
#undef NETWORK_NO_LIB
43
#endif
@@ -10,43 +9,43 @@
109

1110
namespacenetwork {namespacelogging {
1211

13-
namespacehandler
14-
{
15-
namespace
16-
{
17-
voidstd_log_handler(const log_record& log )
18-
{
19-
std::cerr << log.full_message() << std::endl;
20-
}
21-
}
22-
23-
log_record_handlerget_std_log_handler() {return &std_log_handler; }
24-
log_record_handlerget_default_log_handler() {return &std_log_handler; }
25-
}
26-
27-
28-
namespace
29-
{
30-
// the log handler have to manage itself the thread safety on call
31-
log_record_handler current_log_record_handler = handler::std_log_handler;
32-
boost::upgrade_mutex mutex_log_handler;// we still need to not change the log handler concurrently
33-
}
34-
35-
36-
voidset_log_record_handler( log_record_handler handler )
37-
{
38-
boost::lock_guard<boost::upgrade_mutex>write_lock( mutex_log_handler );
39-
current_log_record_handler = handler;
40-
}
41-
42-
voidlog(const log_record& log )
43-
{
44-
boost::shared_lock<boost::upgrade_mutex>read_lock( mutex_log_handler );
45-
if( current_log_record_handler )
46-
{
47-
current_log_record_handler( log );
48-
}
49-
}
12+
namespacehandler
13+
{
14+
namespace
15+
{
16+
voidstd_log_handler(const log_record& log )
17+
{
18+
std::cerr << log.full_message() << std::endl;
19+
}
20+
}
21+
22+
log_record_handlerget_std_log_handler() {return &std_log_handler; }
23+
log_record_handlerget_default_log_handler() {return &std_log_handler; }
24+
}
25+
26+
27+
namespace
28+
{
29+
// the log handler have to manage itself the thread safety on call
30+
log_record_handler current_log_record_handler = handler::std_log_handler;
31+
boost::upgrade_mutex mutex_log_handler;// we still need to not change the log handler concurrently
32+
}
33+
34+
35+
voidset_log_record_handler( log_record_handler handler )
36+
{
37+
boost::lock_guard<boost::upgrade_mutex>write_lock( mutex_log_handler );
38+
current_log_record_handler = handler;
39+
}
40+
41+
voidlog(const log_record& log )
42+
{
43+
boost::shared_lock<boost::upgrade_mutex>read_lock( mutex_log_handler );
44+
if( current_log_record_handler )
45+
{
46+
current_log_record_handler( log );
47+
}
48+
}
5049

5150

5251
}}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp