blob: dc119edfd1d1547274920bd707dce502e66afd23 [file] [log] [blame]
Yuta HIGUCHI02a125e2017-05-05 18:36:21 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Yuta HIGUCHI02a125e2017-05-05 18:36:21 -07003 *
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 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 */
16package org.onosproject.cli;
17
18import static org.slf4j.LoggerFactory.getLogger;
19
20import java.util.List;
21import java.util.stream.Collectors;
22
23import org.apache.karaf.shell.commands.Argument;
24import org.apache.karaf.shell.commands.Command;
25import org.apache.karaf.shell.commands.Option;
26import org.slf4j.Logger;
27
28import com.google.common.collect.ImmutableList;
29
30/**
31 * CLI command which just log message to ONOS log for ease of debugging, etc.
32 */
33@Command(scope = "onos", name = "mark",
34 description = "Mark message in the log")
35public class MarkCommand extends AbstractShellCommand {
36
37 private static final String MARK = "--MARK--";
38
39 @Option(name = "--impersonate",
40 description = "Logger to use when logging this message",
41 required = false, multiValued = false)
42 String loggerName = "org.onosproject.cli.MarkCommand";
43
44 // TODO Option to specify log level
45
46
47 @Argument(index = 0, name = "message", description = "Message to log",
48 required = false, multiValued = true, valueToShowInHelp = MARK)
49 List<String> message = ImmutableList.of(MARK);
50
51 @Override
52 protected void execute() {
53
54 Logger log = getLogger(loggerName);
55
56 log.info("{}", message.stream().collect(Collectors.joining(" ")));
57
58 }
59
60}