-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from intergral/logging
feat(logging): initial implementation of tracepoint logging
- Loading branch information
Showing
34 changed files
with
4,978 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...s/Listen_for_Docker_debug_connections.xml → ...igurations/Connect_to_Remote_Debugger.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
agent-api/src/main/java/com/intergral/deep/agent/api/logger/ITracepointLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2023 Intergral GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.intergral.deep.agent.api.logger; | ||
|
||
/** | ||
* Tracepoint logger is used to log the result of an injected log message. | ||
*/ | ||
public interface ITracepointLogger { | ||
|
||
/** | ||
* Log the result of a tracepoint injected log message. | ||
* | ||
* @param logMsg the processed log message | ||
* @param tracepointId the tracepoint id that triggered the log | ||
* @param snapshotId the snapshot id of the generated snapshot from the log | ||
*/ | ||
void logTracepoint(final String logMsg, final String tracepointId, final String snapshotId); | ||
} |
30 changes: 30 additions & 0 deletions
30
agent-api/src/main/java/com/intergral/deep/agent/api/logger/StdOutLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (C) 2023 Intergral GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.intergral.deep.agent.api.logger; | ||
|
||
/** | ||
* Log the tracepoint logs to {@link System#out}. | ||
*/ | ||
public class StdOutLogger implements ITracepointLogger { | ||
|
||
@Override | ||
public void logTracepoint(final String logMsg, final String tracepointId, final String snapshotId) { | ||
final String format = String.format("%s snapshot=%s tracepoint=%s", logMsg, tracepointId, snapshotId); | ||
System.out.println(format); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
agent-api/src/main/java/com/intergral/deep/agent/api/logger/TracepointLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2023 Intergral GmbH | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.intergral.deep.agent.api.logger; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This is the default tracepoint logger that will log to the default Deep logger. | ||
*/ | ||
public class TracepointLogger implements ITracepointLogger { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(TracepointLogger.class); | ||
|
||
@Override | ||
public void logTracepoint(final String logMsg, final String tracepointId, final String snapshotId) { | ||
final String format = String.format("%s snapshot=%s tracepoint=%s", logMsg, tracepointId, snapshotId); | ||
LOGGER.info(format); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 172 additions & 0 deletions
172
agent-api/src/main/java/com/intergral/deep/agent/api/utils/string/AbstractStringMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache license, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the license for the specific language governing permissions and | ||
* limitations under the license. | ||
*/ | ||
|
||
package com.intergral.deep.agent.api.utils.string; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* A matcher class that can be queried to determine if a character array portion matches. | ||
* <p> | ||
* This class comes complete with various factory methods. If these do not suffice, you can subclass and implement your own matcher. | ||
* | ||
* @since 1.3 | ||
*/ | ||
abstract class AbstractStringMatcher implements StringMatcher { | ||
|
||
/** | ||
* Class used to define a character for matching purposes. | ||
*/ | ||
static final class CharMatcher extends AbstractStringMatcher { | ||
|
||
/** | ||
* The character to match. | ||
*/ | ||
private final char ch; | ||
|
||
/** | ||
* Constructor that creates a matcher that matches a single character. | ||
* | ||
* @param ch the character to match | ||
*/ | ||
CharMatcher(final char ch) { | ||
super(); | ||
this.ch = ch; | ||
} | ||
|
||
/** | ||
* Returns whether or not the given character matches. | ||
* | ||
* @param buffer the text content to match against, do not change | ||
* @param pos the starting position for the match, valid for buffer | ||
* @param bufferStart the first active index in the buffer, valid for buffer | ||
* @param bufferEnd the end index of the active buffer, valid for buffer | ||
* @return the number of matching characters, zero for no match | ||
*/ | ||
@Override | ||
public int isMatch(final char[] buffer, final int pos, final int bufferStart, final int bufferEnd) { | ||
return ch == buffer[pos] ? 1 : 0; | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Class used to match no characters. | ||
*/ | ||
static final class NoMatcher extends AbstractStringMatcher { | ||
|
||
/** | ||
* Constructs a new instance of <code>NoMatcher</code>. | ||
*/ | ||
NoMatcher() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Always returns <code>false</code>. | ||
* | ||
* @param buffer the text content to match against, do not change | ||
* @param pos the starting position for the match, valid for buffer | ||
* @param bufferStart the first active index in the buffer, valid for buffer | ||
* @param bufferEnd the end index of the active buffer, valid for buffer | ||
* @return the number of matching characters, zero for no match | ||
*/ | ||
@Override | ||
public int isMatch(final char[] buffer, final int pos, final int bufferStart, final int bufferEnd) { | ||
return 0; | ||
} | ||
} | ||
|
||
/** | ||
* Class used to define a set of characters for matching purposes. | ||
*/ | ||
static final class StringMatcher extends AbstractStringMatcher { | ||
|
||
/** | ||
* The string to match, as a character array. | ||
*/ | ||
private final char[] chars; | ||
|
||
/** | ||
* Constructor that creates a matcher from a String. | ||
* | ||
* @param str the string to match, must not be null | ||
*/ | ||
StringMatcher(final String str) { | ||
super(); | ||
chars = str.toCharArray(); | ||
} | ||
|
||
/** | ||
* Returns whether or not the given text matches the stored string. | ||
* | ||
* @param buffer the text content to match against, do not change | ||
* @param pos the starting position for the match, valid for buffer | ||
* @param bufferStart the first active index in the buffer, valid for buffer | ||
* @param bufferEnd the end index of the active buffer, valid for buffer | ||
* @return the number of matching characters, zero for no match | ||
*/ | ||
@Override | ||
public int isMatch(final char[] buffer, int pos, final int bufferStart, final int bufferEnd) { | ||
final int len = chars.length; | ||
if (pos + len > bufferEnd) { | ||
return 0; | ||
} | ||
for (int i = 0; i < chars.length; i++, pos++) { | ||
if (chars[i] != buffer[pos]) { | ||
return 0; | ||
} | ||
} | ||
return len; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return super.toString() + ' ' + Arrays.toString(chars); | ||
} | ||
|
||
} | ||
|
||
|
||
/** | ||
* Constructor. | ||
*/ | ||
protected AbstractStringMatcher() { | ||
super(); | ||
} | ||
|
||
/** | ||
* Returns the number of matching characters, zero for no match. | ||
* <p> | ||
* This method is called to check for a match. The parameter <code>pos</code> represents the current position to be checked in the string | ||
* <code>buffer</code> (a character array which must not be changed). The API guarantees that | ||
* <code>pos</code> is a valid index for <code>buffer</code>. | ||
* <p> | ||
* The matching code may check one character or many. It may check characters preceding <code>pos</code> as well as those after. | ||
* <p> | ||
* It must return zero for no match, or a positive number if a match was found. The number indicates the number of characters that | ||
* matched. | ||
* | ||
* @param buffer the text content to match against, do not change | ||
* @param pos the starting position for the match, valid for buffer | ||
* @return the number of matching characters, zero for no match | ||
*/ | ||
public int isMatch(final char[] buffer, final int pos) { | ||
return isMatch(buffer, pos, 0, buffer.length); | ||
} | ||
|
||
} |
Oops, something went wrong.