Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
shop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
shop
Commits
c7202cb3
Commit
c7202cb3
authored
Oct 06, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
9cbdd74b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
AliyunLogProducer.java
...main/java/com/egolm/shop/aliyunLog/AliyunLogProducer.java
+7
-0
ExceptionHandler.java
src/main/java/com/egolm/shop/config/ExceptionHandler.java
+8
-0
No files found.
src/main/java/com/egolm/shop/aliyunLog/AliyunLogProducer.java
View file @
c7202cb3
...
@@ -37,8 +37,15 @@ public class AliyunLogProducer {
...
@@ -37,8 +37,15 @@ public class AliyunLogProducer {
private
static
final
ExecutorService
EXECUTOR_SERVICE
=
Executors
.
newCachedThreadPool
();
private
static
final
ExecutorService
EXECUTOR_SERVICE
=
Executors
.
newCachedThreadPool
();
public
void
sendLog
(
String
logText
)
{
public
void
sendLog
(
String
logText
)
{
if
(!
isOpen
)
{
return
;
}
try
{
try
{
List
<
LogItem
>
logItems
=
new
ArrayList
<
LogItem
>();
List
<
LogItem
>
logItems
=
new
ArrayList
<
LogItem
>();
LogItem
logItem
=
new
LogItem
();
logItem
.
PushBack
(
"id"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
logItem
.
PushBack
(
"logText"
,
logText
);
logItems
.
add
(
logItem
);
ListenableFuture
<
Result
>
future
=
producer
.
send
(
project
,
logStore
,
logItems
);
ListenableFuture
<
Result
>
future
=
producer
.
send
(
project
,
logStore
,
logItems
);
Futures
.
addCallback
(
future
,
new
SampleFutureCallback
(
project
,
logStore
,
logText
),
EXECUTOR_SERVICE
);
Futures
.
addCallback
(
future
,
new
SampleFutureCallback
(
project
,
logStore
,
logText
),
EXECUTOR_SERVICE
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/egolm/shop/config/ExceptionHandler.java
View file @
c7202cb3
...
@@ -5,19 +5,26 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -5,19 +5,26 @@ import javax.servlet.http.HttpServletResponse;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.view.json.MappingJackson2JsonView
;
import
org.springframework.web.servlet.view.json.MappingJackson2JsonView
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.shop.aliyunLog.AliyunLogProducer
;
import
com.egolm.shop.util.I18NUtils
;
import
com.egolm.shop.util.I18NUtils
;
import
io.netty.util.internal.ThrowableUtil
;
@Component
@Component
public
class
ExceptionHandler
implements
HandlerExceptionResolver
{
public
class
ExceptionHandler
implements
HandlerExceptionResolver
{
private
static
final
Log
logger
=
LogFactory
.
getLog
(
ExceptionHandler
.
class
);
private
static
final
Log
logger
=
LogFactory
.
getLog
(
ExceptionHandler
.
class
);
@Autowired
private
AliyunLogProducer
logProducer
;
@Override
@Override
public
ModelAndView
resolveException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
{
public
ModelAndView
resolveException
(
HttpServletRequest
request
,
HttpServletResponse
response
,
Object
handler
,
Exception
ex
)
{
String
langID
=
request
.
getParameter
(
"langID"
);
String
langID
=
request
.
getParameter
(
"langID"
);
...
@@ -33,6 +40,7 @@ public class ExceptionHandler implements HandlerExceptionResolver {
...
@@ -33,6 +40,7 @@ public class ExceptionHandler implements HandlerExceptionResolver {
mav
.
addAllObjects
(
Rjx
.
jsonErr
().
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Exception_processFailure"
)));
mav
.
addAllObjects
(
Rjx
.
jsonErr
().
setMessage
(
I18NUtils
.
getMessage
(
langID
,
"Msg_Exception_processFailure"
)));
}
finally
{
}
finally
{
logger
.
error
(
""
,
ex
);
logger
.
error
(
""
,
ex
);
logProducer
.
sendLog
(
ThrowableUtil
.
stackTraceToString
(
ex
));
}
}
return
mav
;
return
mav
;
}
}
...
...
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