提交 | 用户 | 时间
|
1ac2bc
|
1 |
/** |
懒 |
2 |
* Copyright 2018-2020 stylefeng & fengshuonan (https://gitee.com/stylefeng) |
|
3 |
* <p> |
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
* you may not use this file except in compliance with the License. |
|
6 |
* You may obtain a copy of the License at |
|
7 |
* <p> |
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
* <p> |
|
10 |
* Unless required by applicable law or agreed to in writing, software |
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
* See the License for the specific language governing permissions and |
|
14 |
* limitations under the License. |
|
15 |
*/ |
|
16 |
package cn.stylefeng.guns.sys.core.log; |
|
17 |
|
|
18 |
import java.util.TimerTask; |
|
19 |
import java.util.concurrent.ScheduledThreadPoolExecutor; |
|
20 |
import java.util.concurrent.TimeUnit; |
|
21 |
|
|
22 |
/** |
|
23 |
* 日志管理器 |
|
24 |
* |
|
25 |
* @author fengshuonan |
|
26 |
* @date 2017-03-30 16:29 |
|
27 |
*/ |
|
28 |
public class LogManager { |
|
29 |
|
|
30 |
//日志记录操作延时 |
|
31 |
private final int OPERATE_DELAY_TIME = 10; |
|
32 |
|
|
33 |
//异步操作记录日志的线程池 |
|
34 |
private ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10); |
|
35 |
|
|
36 |
private LogManager() { |
|
37 |
} |
|
38 |
|
|
39 |
public static LogManager logManager = new LogManager(); |
|
40 |
|
|
41 |
public static LogManager me() { |
|
42 |
return logManager; |
|
43 |
} |
|
44 |
|
|
45 |
public void executeLog(TimerTask task) { |
|
46 |
executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS); |
|
47 |
} |
|
48 |
} |