Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
fe4c41e5
Commit
fe4c41e5
authored
Jan 19, 2026
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
codex-added logging helper
parent
efe4ede4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
0 deletions
+112
-0
pom.xml
pom.xml
+24
-0
LogTee.java
src/main/java/com/elphel/imagej/common/LogTee.java
+88
-0
No files found.
pom.xml
View file @
fe4c41e5
...
@@ -97,6 +97,24 @@
...
@@ -97,6 +97,24 @@
<groupId>
ome
</groupId>
<groupId>
ome
</groupId>
<artifactId>
loci_tools
</artifactId>
<artifactId>
loci_tools
</artifactId>
<version>
6.1.0
</version>
<version>
6.1.0
</version>
<exclusions>
<exclusion>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
</exclusion>
<exclusion>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
</exclusion>
<exclusion>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
</exclusion>
<exclusion>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/ome/pom-bio-formats -->
<!-- https://mvnrepository.com/artifact/ome/pom-bio-formats -->
<!-- Was source in attic for development -->
<!-- Was source in attic for development -->
...
@@ -133,6 +151,12 @@
...
@@ -133,6 +151,12 @@
<artifactId>
jcl-over-slf4j
</artifactId>
<artifactId>
jcl-over-slf4j
</artifactId>
<version>
1.7.5
</version>
<version>
1.7.5
</version>
</dependency>
</dependency>
<!-- SLF4J backend (single binding) -->
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<version>
1.1.1
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-numbers-quaternion -->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-numbers-quaternion -->
<!--
<!--
...
...
src/main/java/com/elphel/imagej/common/LogTee.java
0 → 100644
View file @
fe4c41e5
package
com
.
elphel
.
imagej
.
common
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.PrintStream
;
import
java.nio.file.Path
;
/**
* Tee System.out/System.err to a per-scene log file while preserving console output.
* Usage:
* LogTee.install(); // once at startup
* LogTee.setSceneLog(path); // enable per-scene logging (append)
* LogTee.clearSceneLog(); // stop file logging
*/
public
final
class
LogTee
{
private
static
final
Object
LOCK
=
new
Object
();
private
static
final
PrintStream
ORIGINAL_OUT
=
System
.
out
;
private
static
final
PrintStream
ORIGINAL_ERR
=
System
.
err
;
private
static
volatile
PrintStream
fileStream
=
null
;
private
static
volatile
boolean
installed
=
false
;
private
LogTee
()
{
}
public
static
void
install
()
{
synchronized
(
LOCK
)
{
if
(
installed
)
return
;
System
.
setOut
(
new
PrintStream
(
new
TeeStream
(
ORIGINAL_OUT
),
true
));
System
.
setErr
(
new
PrintStream
(
new
TeeStream
(
ORIGINAL_ERR
),
true
));
installed
=
true
;
}
}
public
static
void
setSceneLog
(
Path
path
)
throws
IOException
{
if
(
path
==
null
)
{
clearSceneLog
();
return
;
}
synchronized
(
LOCK
)
{
closeFileStream
();
fileStream
=
new
PrintStream
(
new
FileOutputStream
(
path
.
toFile
(),
true
),
true
);
}
}
public
static
void
clearSceneLog
()
{
synchronized
(
LOCK
)
{
closeFileStream
();
fileStream
=
null
;
}
}
private
static
void
closeFileStream
()
{
if
(
fileStream
!=
null
)
{
fileStream
.
flush
();
fileStream
.
close
();
}
}
private
static
final
class
TeeStream
extends
OutputStream
{
private
final
PrintStream
console
;
private
TeeStream
(
PrintStream
console
)
{
this
.
console
=
console
;
}
@Override
public
void
write
(
int
b
)
throws
IOException
{
console
.
write
(
b
);
PrintStream
fs
=
fileStream
;
if
(
fs
!=
null
)
fs
.
write
(
b
);
}
@Override
public
void
write
(
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
console
.
write
(
b
,
off
,
len
);
PrintStream
fs
=
fileStream
;
if
(
fs
!=
null
)
fs
.
write
(
b
,
off
,
len
);
}
@Override
public
void
flush
()
throws
IOException
{
console
.
flush
();
PrintStream
fs
=
fileStream
;
if
(
fs
!=
null
)
fs
.
flush
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment