Skip to content

Commit fbe696a

Browse files
committed
Start of log sink mapping
Signed-off-by: Ryan Nett <[email protected]>
1 parent 97298ca commit fbe696a

File tree

6 files changed

+626
-2
lines changed

6 files changed

+626
-2
lines changed

tensorflow-core/tensorflow-core-api/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@
212212
<includePaths>
213213
<includePath>${project.basedir}/</includePath>
214214
<includePath>${project.basedir}/bazel-${project.artifactId}/external/org_tensorflow/</includePath>
215+
<includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_absl/</includePath>
216+
<includePath>${project.basedir}/bazel-${project.artifactId}/external/eigen_archive/</includePath>
215217
</includePaths>
216218
<linkPaths>
217219
<linkPath>${project.basedir}/bazel-bin/external/llvm_openmp/</linkPath>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Targeted by JavaCPP version 1.5.4: DO NOT EDIT THIS FILE
2+
3+
package org.tensorflow.internal.c_api;
4+
5+
import java.nio.*;
6+
import org.bytedeco.javacpp.*;
7+
import org.bytedeco.javacpp.annotation.*;
8+
9+
import static org.tensorflow.internal.c_api.global.tensorflow.*;
10+
11+
12+
// This is the default log sink. This log sink is used if there are no other
13+
// log sinks registered. To disable the default log sink, set the
14+
// "no_default_logger" Bazel config setting to true or define a
15+
// NO_DEFAULT_LOGGER preprocessor symbol. This log sink will always log to
16+
// stderr.
17+
@Namespace("tensorflow") @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
18+
public class TFDefaultLogSink extends TFLogSink {
19+
static { Loader.load(); }
20+
/** Default native constructor. */
21+
public TFDefaultLogSink() { super((Pointer)null); allocate(); }
22+
/** Native array allocator. Access with {@link Pointer#position(long)}. */
23+
public TFDefaultLogSink(long size) { super((Pointer)null); allocateArray(size); }
24+
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
25+
public TFDefaultLogSink(Pointer p) { super(p); }
26+
private native void allocate();
27+
private native void allocateArray(long size);
28+
@Override public TFDefaultLogSink position(long position) {
29+
return (TFDefaultLogSink)super.position(position);
30+
}
31+
@Override public TFDefaultLogSink getPointer(long i) {
32+
return new TFDefaultLogSink(this).position(position + i);
33+
}
34+
35+
public native void Send(@Const @ByRef TFLogEntry entry);
36+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Targeted by JavaCPP version 1.5.4: DO NOT EDIT THIS FILE
2+
3+
package org.tensorflow.internal.c_api;
4+
5+
import java.nio.*;
6+
import org.bytedeco.javacpp.*;
7+
import org.bytedeco.javacpp.annotation.*;
8+
9+
import static org.tensorflow.internal.c_api.global.tensorflow.*;
10+
// namespace internal
11+
12+
// LogSink support adapted from //base/logging.h
13+
//
14+
// `LogSink` is an interface which can be extended to intercept and process
15+
// all log messages. LogSink implementations must be thread-safe. A single
16+
// instance will be called from whichever thread is performing a logging
17+
// operation.
18+
@Namespace("tensorflow") @NoOffset @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
19+
public class TFLogEntry extends Pointer {
20+
static { Loader.load(); }
21+
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
22+
public TFLogEntry(Pointer p) { super(p); }
23+
24+
public TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer message) { super((Pointer)null); allocate(severity, message); }
25+
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer message);
26+
public TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) String message) { super((Pointer)null); allocate(severity, message); }
27+
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) String message);
28+
29+
public TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer fname, int line,
30+
@StdString @Cast({"char*", "std::string&&"}) BytePointer message) { super((Pointer)null); allocate(severity, fname, line, message); }
31+
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) BytePointer fname, int line,
32+
@StdString @Cast({"char*", "std::string&&"}) BytePointer message);
33+
public TFLogEntry(int severity, @StdString @Cast({"char*", "std::string&&"}) String fname, int line,
34+
@StdString @Cast({"char*", "std::string&&"}) String message) { super((Pointer)null); allocate(severity, fname, line, message); }
35+
private native void allocate(int severity, @StdString @Cast({"char*", "std::string&&"}) String fname, int line,
36+
@StdString @Cast({"char*", "std::string&&"}) String message);
37+
38+
public native @Cast("absl::LogSeverity") int log_severity();
39+
public native @StdString @Cast({"char*", "std::string&&"}) BytePointer FName();
40+
public native int Line();
41+
public native @StdString @Cast({"char*", "std::string&&"}) BytePointer ToString();
42+
public native @StdString @Cast({"char*", "std::string&&"}) BytePointer text_message();
43+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Targeted by JavaCPP version 1.5.4: DO NOT EDIT THIS FILE
2+
3+
package org.tensorflow.internal.c_api;
4+
5+
import java.nio.*;
6+
import org.bytedeco.javacpp.*;
7+
import org.bytedeco.javacpp.annotation.*;
8+
9+
import static org.tensorflow.internal.c_api.global.tensorflow.*;
10+
11+
12+
@Namespace("tensorflow") @Properties(inherit = org.tensorflow.internal.c_api.presets.tensorflow.class)
13+
public class TFLogSink extends Pointer {
14+
static { Loader.load(); }
15+
/** Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}. */
16+
public TFLogSink(Pointer p) { super(p); }
17+
18+
19+
// `Send` is called synchronously during the log statement. The logging
20+
// module guarantees not to call `Send` concurrently on the same log sink.
21+
// Implementations should be careful not to call`LOG` or `CHECK` or take
22+
// any locks that might be held by the `LOG` caller, to avoid deadlock.
23+
//
24+
// `e` is guaranteed to remain valid until the subsequent call to
25+
// `WaitTillSent` completes, so implementations may store a pointer to or
26+
// copy of `e` (e.g. in a thread local variable) for use in `WaitTillSent`.
27+
public native void Send(@Const @ByRef TFLogEntry entry);
28+
29+
// `WaitTillSent` blocks the calling thread (the thread that generated a log
30+
// message) until the sink has finished processing the log message.
31+
// `WaitTillSent` is called once per log message, following the call to
32+
// `Send`. This may be useful when log messages are buffered or processed
33+
// asynchronously by an expensive log sink.
34+
// The default implementation returns immediately. Like `Send`,
35+
// implementations should be careful not to call `LOG` or `CHECK or take any
36+
// locks that might be held by the `LOG` caller, to avoid deadlock.
37+
public native void WaitTillSent();
38+
}

0 commit comments

Comments
 (0)