Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.cpp
/
Microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a9d3b969
authored
May 03, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add colorful logging
parent
85220c52
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
2 deletions
CMakeLists.txt
README.md
doc/todo.txt
src/impl/Microservices_ILoggerLog4cppImpl.cpp
src/impl/Microservices_ILoggerLog4cppImpl.h
CMakeLists.txt
View file @
a9d3b969
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)
...
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)
project
(
Microservice
)
project
(
Microservice
)
# version stuff
# version stuff
set
(
Microservice_VERSION_MAJOR 1
)
set
(
Microservice_VERSION_MAJOR 1
)
set
(
Microservice_VERSION_MINOR
3
)
set
(
Microservice_VERSION_MINOR
4
)
set
(
Microservice_VERSION_PATCH 0
)
set
(
Microservice_VERSION_PATCH 0
)
set
(
Microservice_VERSION_STRING
${
Microservice_VERSION_MAJOR
}
.
${
Microservice_VERSION_MINOR
}
.
${
Microservice_VERSION_PATCH
}
)
set
(
Microservice_VERSION_STRING
${
Microservice_VERSION_MAJOR
}
.
${
Microservice_VERSION_MINOR
}
.
${
Microservice_VERSION_PATCH
}
)
...
...
README.md
View file @
a9d3b969
## C++ Microservice Framework
## C++ Microservice Framework
## VERSIONS:
## VERSIONS:
# 1.4.0
-
Add colorful logging
# 1.3.0
# 1.3.0
-
Async Rest Client/Server using ZMQ
-
Async Rest Client/Server using ZMQ
-
Add gethrtime in CommonUtils to get timestamp (nanoseconds , not for datetime)
-
Add gethrtime in CommonUtils to get timestamp (nanoseconds , not for datetime)
...
...
doc/todo.txt
View file @
a9d3b969
- memory leak on performance testing of SendZmqRestRequests
- memory leak on performance testing of SendZmqRestRequests
- upon receiving the response , forward it to a new task to be carried by another thread
- upon receiving the response , forward it to a new task to be carried by another thread
- catch http exception when callback url is down
\ No newline at end of file
src/impl/Microservices_ILoggerLog4cppImpl.cpp
View file @
a9d3b969
...
@@ -21,10 +21,64 @@
...
@@ -21,10 +21,64 @@
#include <log4cpp/PatternLayout.hh>
#include <log4cpp/PatternLayout.hh>
thread_local
char
ba_LogBuffer
[
nsMicroservice_Constants
::
MAX_LOGEER_BUFF_LENGTH
];
thread_local
char
ba_LogBuffer
[
nsMicroservice_Constants
::
MAX_LOGEER_BUFF_LENGTH
];
#define RST "\x1B[0m"
#define KRED "\x1B[31m"
#define KGRN "\x1B[32m"
#define KYEL "\x1B[33m"
#define KBLU "\x1B[34m"
#define KMAG "\x1B[35m"
#define KCYN "\x1B[36m"
#define KWHT "\x1B[37m"
#define FRED(x) KRED x RST
#define FGRN(x) KGRN x RST
#define FYEL(x) KYEL x RST
#define FBLU(x) KBLU x RST
#define FMAG(x) KMAG x RST
#define FCYN(x) KCYN x RST
#define FWHT(x) KWHT x RST
#define BOLD(x) "\x1B[1m" x RST
#define UNDL(x) "\x1B[4m" x RST
#define MAKE_MESSAGE {int len; va_list ap; va_start( ap , stringFormat );\
#define MAKE_MESSAGE {int len; va_list ap; va_start( ap , stringFormat );\
len = ( vsnprintf(ba_LogBuffer, nsMicroservice_Constants::MAX_LOGEER_BUFF_LENGTH, stringFormat, ap ) ); va_end(ap);}
len = ( vsnprintf(ba_LogBuffer, nsMicroservice_Constants::MAX_LOGEER_BUFF_LENGTH, stringFormat, ap ) ); va_end(ap);}
/**
* class for output to console in colors....yeah
*/
class
cMicroservices_ILoggerLog4cppImpl
::
ColorOstreamAppender
:
public
log4cpp
::
OstreamAppender
{
public
:
ColorOstreamAppender
(
const
std
::
string
&
name
,
std
::
ostream
*
stream
)
:
OstreamAppender
(
name
,
stream
)
{}
protected
:
void
_append
(
const
log4cpp
::
LoggingEvent
&
event
)
override
{
switch
(
event
.
priority
){
case
log4cpp
:
:
Priority
::
ALERT
:
case
log4cpp
:
:
Priority
::
ERROR
:
case
log4cpp
:
:
Priority
::
CRIT
:
case
log4cpp
:
:
Priority
::
FATAL
:
(
*
_stream
)
<<
KRED
<<
_getLayout
().
format
(
event
)
<<
RST
;
break
;
case
log4cpp
:
:
Priority
::
INFO
:
(
*
_stream
)
<<
KBLU
<<
_getLayout
().
format
(
event
)
<<
RST
;
break
;
case
log4cpp
:
:
Priority
::
NOTICE
:
(
*
_stream
)
<<
KGRN
<<
_getLayout
().
format
(
event
)
<<
RST
;
break
;
case
log4cpp
:
:
Priority
::
WARN
:
(
*
_stream
)
<<
KYEL
<<
_getLayout
().
format
(
event
)
<<
RST
;
break
;
case
log4cpp
:
:
Priority
::
DEBUG
:
(
*
_stream
)
<<
KWHT
<<
_getLayout
().
format
(
event
)
<<
RST
;
break
;
}
}
};
/**
/**
*
*
* @param name
* @param name
...
@@ -37,7 +91,7 @@ void cMicroservices_ILoggerLog4cppImpl::initDefaultLogger(const char* name){
...
@@ -37,7 +91,7 @@ void cMicroservices_ILoggerLog4cppImpl::initDefaultLogger(const char* name){
char
*
logToConsole
=
getenv
(
"log4cpp.console"
);
char
*
logToConsole
=
getenv
(
"log4cpp.console"
);
if
(
logToConsole
)
if
(
logToConsole
)
{
{
consuleAappender
=
new
log4cpp
::
OstreamAppender
(
"console"
,
&
std
::
cout
);
consuleAappender
=
new
ColorOstreamAppender
(
"console"
,
&
std
::
cout
);
//
log4cpp::OstreamAppender("console", &std::cout);
log4cpp
::
PatternLayout
*
consoleLayout
=
new
log4cpp
::
PatternLayout
();
log4cpp
::
PatternLayout
*
consoleLayout
=
new
log4cpp
::
PatternLayout
();
consoleLayout
->
setConversionPattern
(
layoutPattern
);
consoleLayout
->
setConversionPattern
(
layoutPattern
);
consuleAappender
->
setLayout
(
consoleLayout
);
consuleAappender
->
setLayout
(
consoleLayout
);
...
...
src/impl/Microservices_ILoggerLog4cppImpl.h
View file @
a9d3b969
...
@@ -20,6 +20,9 @@
...
@@ -20,6 +20,9 @@
class
cMicroservices_ILoggerLog4cppImpl
:
public
nsMicroservice_Iface
::
ILogger
class
cMicroservices_ILoggerLog4cppImpl
:
public
nsMicroservice_Iface
::
ILogger
{
{
public
:
class
ColorOstreamAppender
;
private
:
private
:
log4cpp
::
Category
*
mpc_Logger
;
log4cpp
::
Category
*
mpc_Logger
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment