Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Social Cognitive Systems
ipaaca
Commits
f671efb6
Commit
f671efb6
authored
9 years ago
by
Hendrik Buschmeier
Browse files
Options
Downloads
Patches
Plain Diff
ipaaca-java: IpaacaLogger now sends/logs callers fully qualified name.
parent
72ff3421
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ipaacalib/java/src/ipaaca/util/IpaacaLogger.java
+42
-41
42 additions, 41 deletions
ipaacalib/java/src/ipaaca/util/IpaacaLogger.java
with
42 additions
and
41 deletions
ipaacalib/java/src/ipaaca/util/IpaacaLogger.java
+
42
−
41
View file @
f671efb6
...
...
@@ -44,10 +44,10 @@ public class IpaacaLogger {
private
static
OutputBuffer
ob
;
private
static
final
Object
lock
=
new
Object
();
private
static
boolean
SEND_IPAACA_LOGS
=
true
;
private
static
String
MODULE_NAME
=
"???"
;
private
static
void
initializeOutBuffer
()
{
synchronized
(
lock
)
{
if
(
ob
==
null
)
{
...
...
@@ -55,13 +55,13 @@ public class IpaacaLogger {
}
}
}
public
static
void
setModuleName
(
String
name
)
{
synchronized
(
lock
)
{
MODULE_NAME
=
name
;
}
}
public
static
void
setLogFileName
(
String
fileName
,
String
logMode
)
{
initializeOutBuffer
();
LocalMessageIU
msg
=
new
LocalMessageIU
(
"log"
);
...
...
@@ -74,19 +74,19 @@ public class IpaacaLogger {
logMode
.
equals
(
"timestamp"
))
{
pl
.
put
(
"existing"
,
logMode
);
}
else
{
return
;
}
}
ob
.
add
(
msg
);
}
public
static
void
sendIpaacaLogs
(
boolean
flag
)
{
synchronized
(
lock
)
{
SEND_IPAACA_LOGS
=
flag
;
}
}
private
static
void
logConsole
(
String
level
,
String
text
,
float
now
,
String
function
,
String
thread
)
{
for
(
String
line:
text
.
split
(
"\n"
))
{
System
.
out
.
println
(
"["
+
level
+
"] "
+
thread
+
" "
+
function
+
" "
+
line
);
...
...
@@ -94,7 +94,7 @@ public class IpaacaLogger {
thread
=
StringUtils
.
leftPad
(
""
,
thread
.
length
(),
' '
);
}
}
private
static
void
logIpaaca
(
String
level
,
String
text
,
float
now
,
String
function
,
String
thread
)
{
initializeOutBuffer
();
LocalMessageIU
msg
=
new
LocalMessageIU
(
"log"
);
...
...
@@ -110,16 +110,20 @@ public class IpaacaLogger {
ob
.
add
(
msg
);
}
private
static
String
getCallerName
()
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
3
].
getClassName
();
function
+=
"."
+
Thread
.
currentThread
().
getStackTrace
()[
3
].
getMethodName
();
return
function
;
}
public
static
void
logError
(
String
msg
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logError
(
msg
,
System
.
currentTimeMillis
(),
function
);
logError
(
msg
,
System
.
currentTimeMillis
(),
getCallerName
());
}
public
static
void
logError
(
String
msg
,
float
now
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logError
(
msg
,
now
,
function
);
logError
(
msg
,
now
,
getCallerName
());
}
private
static
void
logError
(
String
msg
,
float
now
,
String
callerName
)
{
String
thread
=
Thread
.
currentThread
().
getName
();
if
(
SEND_IPAACA_LOGS
)
{
...
...
@@ -127,59 +131,56 @@ public class IpaacaLogger {
}
logConsole
(
"ERROR"
,
msg
,
now
,
callerName
,
thread
);
}
public
static
void
logWarn
(
String
msg
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logWarn
(
msg
,
System
.
currentTimeMillis
(),
function
);
logWarn
(
msg
,
System
.
currentTimeMillis
(),
getCallerName
());
}
public
static
void
logWarn
(
String
msg
,
float
now
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logWarn
(
msg
,
now
,
function
);
logWarn
(
msg
,
now
,
getCallerName
());
}
private
static
void
logWarn
(
String
msg
,
float
now
,
String
callerName
)
{
String
thread
=
Thread
.
currentThread
().
getName
();
if
(
SEND_IPAACA_LOGS
)
{
logIpaaca
(
"WARN"
,
msg
,
now
,
"???"
,
thread
);
logIpaaca
(
"WARN"
,
msg
,
now
,
callerName
,
thread
);
}
logConsole
(
"WARN"
,
msg
,
now
,
"???"
,
thread
);
logConsole
(
"WARN"
,
msg
,
now
,
callerName
,
thread
);
}
public
static
void
logInfo
(
String
msg
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logInfo
(
msg
,
System
.
currentTimeMillis
(),
function
);
logInfo
(
msg
,
System
.
currentTimeMillis
(),
getCallerName
());
}
public
static
void
logInfo
(
String
msg
,
float
now
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logInfo
(
msg
,
now
,
function
);
logInfo
(
msg
,
now
,
getCallerName
());
}
private
static
void
logInfo
(
String
msg
,
float
now
,
String
callerName
)
{
String
thread
=
Thread
.
currentThread
().
getName
();
if
(
SEND_IPAACA_LOGS
)
{
logIpaaca
(
"INFO"
,
msg
,
now
,
"???"
,
thread
);
logIpaaca
(
"INFO"
,
msg
,
now
,
callerName
,
thread
);
}
logConsole
(
"INFO"
,
msg
,
now
,
"???"
,
thread
);
logConsole
(
"INFO"
,
msg
,
now
,
callerName
,
thread
);
}
public
static
void
logDebug
(
String
msg
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logDebug
(
msg
,
System
.
currentTimeMillis
(),
function
);
logDebug
(
msg
,
System
.
currentTimeMillis
(),
getCallerName
());
}
public
static
void
logDebug
(
String
msg
,
float
now
)
{
String
function
=
Thread
.
currentThread
().
getStackTrace
()[
2
].
getMethodName
();
logDebug
(
msg
,
now
,
function
);
logDebug
(
msg
,
now
,
getCallerName
());
}
private
static
void
logDebug
(
String
msg
,
float
now
,
String
callerName
)
{
String
thread
=
Thread
.
currentThread
().
getName
();
if
(
SEND_IPAACA_LOGS
)
{
logIpaaca
(
"DEBUG"
,
msg
,
now
,
"???"
,
thread
);
logIpaaca
(
"DEBUG"
,
msg
,
now
,
callerName
,
thread
);
}
logConsole
(
"DEBUG"
,
msg
,
now
,
"???"
,
thread
);
logConsole
(
"DEBUG"
,
msg
,
now
,
callerName
,
thread
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment