Skip to content

Commit 3fdbc8a

Browse files
committed
adds clang-format file, formats all files
1 parent 89e767f commit 3fdbc8a

10 files changed

Lines changed: 382 additions & 383 deletions

File tree

.clang-format

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
# built with: https://zed0.co.uk/clang-format-configurator/
3+
AccessModifierOffset: '-4'
4+
AlignAfterOpenBracket: DontAlign
5+
AlignConsecutiveAssignments: 'false'
6+
AlignConsecutiveDeclarations: 'false'
7+
AlignOperands: 'false'
8+
AlignTrailingComments: 'true'
9+
AllowShortBlocksOnASingleLine: 'false'
10+
AllowShortCaseLabelsOnASingleLine: 'false'
11+
AllowShortFunctionsOnASingleLine: Empty
12+
AllowShortIfStatementsOnASingleLine: 'false'
13+
AllowShortLoopsOnASingleLine: 'false'
14+
AlwaysBreakAfterDefinitionReturnType: None
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: 'true'
17+
AlwaysBreakTemplateDeclarations: 'true'
18+
BreakBeforeBinaryOperators: None
19+
BreakBeforeBraces: Allman
20+
BreakBeforeTernaryOperators: 'false'
21+
BreakConstructorInitializersBeforeComma: 'false'
22+
BreakConstructorInitializers: AfterColon
23+
ColumnLimit: '120'
24+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
25+
ConstructorInitializerIndentWidth: '4'
26+
ContinuationIndentWidth: '4'
27+
Cpp11BracedListStyle: 'true'
28+
IndentCaseLabels: 'false'
29+
IndentWidth: '4'
30+
KeepEmptyLinesAtTheStartOfBlocks: 'false'
31+
Language: Cpp
32+
MaxEmptyLinesToKeep: '1'
33+
NamespaceIndentation: All
34+
PointerAlignment: Left
35+
ReflowComments: 'true'
36+
SortIncludes: 'true'
37+
SpaceAfterCStyleCast: 'true'
38+
SpaceBeforeAssignmentOperators: 'true'
39+
SpaceBeforeParens: Never
40+
SpaceInEmptyParentheses: 'false'
41+
SpacesInAngles: 'false'
42+
SpacesInCStyleCastParentheses: 'false'
43+
SpacesInParentheses: 'false'
44+
SpacesInSquareBrackets: 'false'
45+
Standard: Cpp11
46+
TabWidth: '4'
47+
UseTab: Never
48+
49+
...

.gitignore

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,5 @@
1-
# Compiled Object files
2-
*.slo
3-
*.lo
4-
*.o
5-
*.obj
6-
7-
# Precompiled Headers
8-
*.gch
9-
*.pch
10-
11-
# Compiled Dynamic libraries
12-
*.so
13-
*.dylib
14-
*.dll
15-
16-
# Fortran module files
17-
*.mod
18-
*.smod
19-
20-
# Compiled Static libraries
21-
*.lai
22-
*.la
23-
*.a
24-
*.lib
25-
26-
# Executables
27-
*.exe
28-
*.out
29-
*.app
30-
31-
#CMake
32-
CMakeFiles/
33-
CMakeCache.txt
1+
# Default build directory
342
build/
35-
Makefile
36-
cmake_install.cmake
37-
compile_commands.json
38-
/install_manifest.txt
39-
/cpplog-exports.cmake
403

414
#Netbeans
425
nbproject/

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ cmake_minimum_required (VERSION 3.1)
44
set(CMAKE_CXX_STANDARD 11)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
7+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
78

89
project (cpplog VERSION 0.4)
910

include/log.h

Lines changed: 73 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* File: log.h
33
* Author: doe300
44
*
@@ -14,81 +14,80 @@
1414

1515
namespace CPPLOG_NAMESPACE
1616
{
17-
18-
/*!
19-
* The log-level
20-
*/
21-
enum class Level : unsigned char
22-
{
23-
DEBUG = 'D',
24-
INFO = 'I',
25-
//something is not as expected
26-
WARNING = 'W',
27-
//program-error
28-
ERROR = 'E',
29-
//critical software-error
30-
SEVERE = 'S'
31-
};
32-
33-
std::wostream& log(Level level);
34-
std::wostream& endl(std::wostream& stream);
35-
36-
inline std::wostream& debug()
37-
{
38-
return CPPLOG_NAMESPACE::log(Level::DEBUG);
39-
}
40-
41-
inline std::wostream& info()
42-
{
43-
return CPPLOG_NAMESPACE::log(Level::INFO);
44-
}
45-
46-
inline std::wostream& warn()
47-
{
48-
return CPPLOG_NAMESPACE::log(Level::WARNING);
49-
}
50-
51-
inline std::wostream& error()
52-
{
53-
return CPPLOG_NAMESPACE::log(Level::ERROR);
54-
}
55-
56-
inline std::wostream& severe()
57-
{
58-
return CPPLOG_NAMESPACE::log(Level::SEVERE);
59-
}
60-
61-
void logf(Level level, const wchar_t* format, ...);
62-
63-
/*!
64-
* Wrapper around a logging statement to only execute it if the level of logging
65-
* will be written to the output.
66-
* This can be used to skip complex logging statements when not required.
67-
*/
68-
void logLazy(Level level, std::function<void(std::wostream&)>&& statement);
69-
70-
/*!
71-
* Wrapper around several logging statements to only execute them if the level of
72-
* logging will be written to the output.
73-
* This can be used to skip complex logging statements when not required.
74-
*/
75-
void logLazy(Level level, std::function<void()>&& statement);
76-
77-
//Forward-declaration for the logger-instance
78-
class Logger;
79-
/*!
80-
* This is the Logger-instance being used to write the logs.
81-
*
82-
* Use this variable to set a custom Logger-instance.
83-
* To disable logging (or stopping running logging), set this LOGGER to nullptr
84-
*/
85-
extern std::unique_ptr<Logger> LOGGER;
86-
}
17+
/*!
18+
* The log-level
19+
*/
20+
enum class Level : unsigned char
21+
{
22+
DEBUG = 'D',
23+
INFO = 'I',
24+
// something is not as expected
25+
WARNING = 'W',
26+
// program-error
27+
ERROR = 'E',
28+
// critical software-error
29+
SEVERE = 'S'
30+
};
31+
32+
std::wostream& log(Level level);
33+
std::wostream& endl(std::wostream& stream);
34+
35+
inline std::wostream& debug()
36+
{
37+
return CPPLOG_NAMESPACE::log(Level::DEBUG);
38+
}
39+
40+
inline std::wostream& info()
41+
{
42+
return CPPLOG_NAMESPACE::log(Level::INFO);
43+
}
44+
45+
inline std::wostream& warn()
46+
{
47+
return CPPLOG_NAMESPACE::log(Level::WARNING);
48+
}
49+
50+
inline std::wostream& error()
51+
{
52+
return CPPLOG_NAMESPACE::log(Level::ERROR);
53+
}
54+
55+
inline std::wostream& severe()
56+
{
57+
return CPPLOG_NAMESPACE::log(Level::SEVERE);
58+
}
59+
60+
void logf(Level level, const wchar_t* format, ...);
61+
62+
/*!
63+
* Wrapper around a logging statement to only execute it if the level of logging
64+
* will be written to the output.
65+
* This can be used to skip complex logging statements when not required.
66+
*/
67+
void logLazy(Level level, std::function<void(std::wostream&)>&& statement);
68+
69+
/*!
70+
* Wrapper around several logging statements to only execute them if the level of
71+
* logging will be written to the output.
72+
* This can be used to skip complex logging statements when not required.
73+
*/
74+
void logLazy(Level level, std::function<void()>&& statement);
75+
76+
// Forward-declaration for the logger-instance
77+
class Logger;
78+
/*!
79+
* This is the Logger-instance being used to write the logs.
80+
*
81+
* Use this variable to set a custom Logger-instance.
82+
* To disable logging (or stopping running logging), set this LOGGER to nullptr
83+
*/
84+
extern std::unique_ptr<Logger> LOGGER;
85+
} // namespace CPPLOG_NAMESPACE
8786

8887
/*!
8988
* Convenience-wrapper to allow writing std::string into std::wostream
9089
*/
91-
std::wostream& operator <<(std::wostream& stream, const std::string& string);
90+
std::wostream& operator<<(std::wostream& stream, const std::string& string);
9291

9392
/*!
9493
* Convenience macro for lazy logging.
@@ -97,21 +96,14 @@ std::wostream& operator <<(std::wostream& stream, const std::string& string);
9796
* Example usage:
9897
* CPPLOG_LAZY(Level::DEBUG, log << "Hello World! << endl);
9998
*/
100-
#define CPPLOG_LAZY(level, content) \
101-
CPPLOG_NAMESPACE::logLazy(level, [&](std::wostream& log){ \
102-
content; \
103-
})\
99+
#define CPPLOG_LAZY(level, content) CPPLOG_NAMESPACE::logLazy(level, [&](std::wostream& log) { content; })
104100

105101
/*!
106102
* Convenience macro for lazy logging.
107103
*
108104
* Example usage:
109105
* CPPLOG_LAZY(Level::DEBUG, debug() << "Hello World! << endl; debug() << "Second statement!" << endl);
110106
*/
111-
#define CPPLOG_LAZY_BLOCK(level, content) \
112-
CPPLOG_NAMESPACE::logLazy(level, [&](){ \
113-
content; \
114-
})\
107+
#define CPPLOG_LAZY_BLOCK(level, content) CPPLOG_NAMESPACE::logLazy(level, [&]() { content; })
115108

116109
#endif /* LOG_H */
117-

0 commit comments

Comments
 (0)