Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ilgooz/service-bluelogger
BlueLogger is a logger service for MESG
https://github.com/ilgooz/service-bluelogger
Last synced: 25 days ago
JSON representation
BlueLogger is a logger service for MESG
- Host: GitHub
- URL: https://github.com/ilgooz/service-bluelogger
- Owner: ilgooz
- License: mit
- Created: 2018-07-24T08:48:58.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-06-08T10:44:39.000Z (over 4 years ago)
- Last Synced: 2024-08-04T20:02:07.978Z (3 months ago)
- Language: Go
- Homepage:
- Size: 3.75 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome - BlueLogger - Log your data to standard output. (Logging)
README
# BlueLogger
BlueLogger is a logger service for [MESG](https://mesg.tech).
## Installation
`$ mesg-core service deploy https://github.com/ilgooz/service-bluelogger`## Tasks
Tasks of the logger service### log
Logs input data to standard output.
#### Input Data
* ServiceID `(string)`
ID of the service that `Data` received from.
* Data `(object)`
Actual log message#### Output Data
* Success: OK `(bool)`
* Error: Message `(string)`## Sample usage in your MESG Application
```go
package mainimport (
"log"mesg "github.com/mesg-foundation/go-application"
)const (
discordServiceID = "fill here with the id of the service to log it's task outputs"
loggerServiceID = "fill here with the logger service's id"
)type logRequest struct {
ServiceID string `json:"serviceID"`
Data interface{} `json:"data"`
}func main() {
app, err := mesg.New()
if err != nil {
log.Fatal(err)
}// 1- wait for send task's results from Discord service.
// 2- send the results to log service with service id of Discord.
_, err := app.
WhenResult(discordServiceID, mesg.TaskFilterOption("send")).
Filter(func(r *mesg.Result) bool {
var resp interface{}
return r.Data(&resp) == nil
}).
Map(func(r *mesg.Result) mesg.Data {
var resp interface{}
r.Data(&resp)
return logRequest{
ServiceID: discordServiceID,
Data: resp,
}
}).
Execute(loggerServiceID, "log")
if err != nil {
log.Fatal(err)
}
}
```