Skip to content

Commit 7892b56

Browse files
brigibodrov
authored andcommitted
STRDTORC-1049: log-tasks: create separate tasks for warn, error and debug levels (walmartlabs#1035)
1 parent 490de6a commit 7892b56

File tree

6 files changed

+167
-0
lines changed

6 files changed

+167
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Added
66

7+
- log-tasks: `logDebug`, `logWarn` and `logError` tasks;
78
- concord-server: initial support for RBAC permissions;
89
- ansible: initial Kerberos authentication support.
910

examples/loglevel/concord.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
configuration:
2+
arguments:
3+
name: "Concord"
4+
runner:
5+
logLevel: "DEBUG"
6+
7+
flows:
8+
default:
9+
- ${log.debug("This is a debug log")}
10+
- ${log.info("This is a info log")}
11+
- ${log.warn("This is a warn log")}
12+
- ${log.error("This is a error log")}
13+
14+
- logDebug: "Hello, ${name}. This is a debug log"
15+
- log: "Hello, ${name}. This is a normal log"
16+
- logWarn: "Hello, ${name}. This is a warn log"
17+
- logError: "Hello, ${name}. This is a error log"

examples/loglevel/run.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
SERVER_ADDR="$1"
4+
5+
rm -rf target && mkdir target
6+
cp -R concord.yml target/
7+
8+
cd target && zip -r payload.zip ./* > /dev/null && cd ..
9+
10+
read -p "Username: " CURL_USER
11+
curl -u ${CURL_USER} -F archive=@target/payload.zip http://${SERVER_ADDR}/api/v1/process
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.walmartlabs.concord.plugins.log;
2+
3+
/*-
4+
* *****
5+
* Concord
6+
* -----
7+
* Copyright (C) 2017 - 2018 Walmart Inc.
8+
* -----
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* =====
21+
*/
22+
23+
import com.walmartlabs.concord.sdk.Context;
24+
import com.walmartlabs.concord.sdk.Task;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
28+
import javax.inject.Named;
29+
30+
import static com.walmartlabs.concord.sdk.ContextUtils.assertString;
31+
32+
@Named("logDebug")
33+
public class LogDebugTask implements Task {
34+
35+
public static final Logger log = LoggerFactory.getLogger(LogDebugTask.class);
36+
37+
public void call(String s) {
38+
log.debug(s);
39+
}
40+
41+
@Override
42+
public void execute(Context ctx) {
43+
String msg = assertString(ctx, "msg");
44+
log.debug(msg);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.walmartlabs.concord.plugins.log;
2+
3+
/*-
4+
* *****
5+
* Concord
6+
* -----
7+
* Copyright (C) 2017 - 2018 Walmart Inc.
8+
* -----
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* =====
21+
*/
22+
23+
import com.walmartlabs.concord.sdk.Context;
24+
import com.walmartlabs.concord.sdk.Task;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
28+
import javax.inject.Named;
29+
30+
import static com.walmartlabs.concord.sdk.ContextUtils.assertString;
31+
32+
@Named("logError")
33+
public class LogErrorTask implements Task {
34+
35+
public static final Logger log = LoggerFactory.getLogger(LogErrorTask.class);
36+
37+
public void call(String s) {
38+
log.error(s);
39+
}
40+
41+
@Override
42+
public void execute(Context ctx) {
43+
String msg = assertString(ctx, "msg");
44+
log.error(msg);
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.walmartlabs.concord.plugins.log;
2+
3+
/*-
4+
* *****
5+
* Concord
6+
* -----
7+
* Copyright (C) 2017 - 2018 Walmart Inc.
8+
* -----
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
* Unless required by applicable law or agreed to in writing, software
16+
* distributed under the License is distributed on an "AS IS" BASIS,
17+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
* See the License for the specific language governing permissions and
19+
* limitations under the License.
20+
* =====
21+
*/
22+
23+
import com.walmartlabs.concord.sdk.Context;
24+
import com.walmartlabs.concord.sdk.Task;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
27+
28+
import javax.inject.Named;
29+
30+
import static com.walmartlabs.concord.sdk.ContextUtils.assertString;
31+
32+
@Named("logWarn")
33+
public class LogWarnTask implements Task {
34+
35+
public static final Logger log = LoggerFactory.getLogger(LogWarnTask.class);
36+
37+
public void call(String s) {
38+
log.warn(s);
39+
}
40+
41+
@Override
42+
public void execute(Context ctx) {
43+
String msg = assertString(ctx, "msg");
44+
log.warn(msg);
45+
}
46+
}

0 commit comments

Comments
 (0)