-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wallet address for Graylog originHost
- Loading branch information
1 parent
d772aec
commit bc34af0
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/main/java/com/iexec/core/log/IexecGelfLogbackAppender.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,45 @@ | ||
package com.iexec.core.log; | ||
|
||
import biz.paluch.logging.gelf.logback.GelfLogbackAppender; | ||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import com.iexec.core.chain.CredentialsService; | ||
import org.springframework.beans.BeansException; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.ApplicationContextAware; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class IexecGelfLogbackAppender extends GelfLogbackAppender implements ApplicationContextAware { | ||
|
||
private static String address; | ||
|
||
public IexecGelfLogbackAppender() { | ||
super(); | ||
} | ||
|
||
/* | ||
* Graylog note: The `originHost` will only contain what we want after CredentialService is loaded. | ||
* | ||
* Very first logs will have: | ||
* originHost=user@user.com | ||
* Next logs will have: | ||
* originHost=0x12..34 | ||
* | ||
* */ | ||
@Override | ||
protected void append(ILoggingEvent event) { | ||
if (address != null) { | ||
gelfMessageAssembler.setOriginHost(address); | ||
} | ||
super.append(event); | ||
} | ||
|
||
@Override | ||
public void setApplicationContext(@NonNull ApplicationContext applicationContext) throws BeansException { | ||
CredentialsService credentialsService = (CredentialsService) applicationContext | ||
.getAutowireCapableBeanFactory().getBean("credentialsService"); | ||
address = credentialsService.getCredentials().getAddress(); | ||
} | ||
} | ||
|
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