Skip to content

Commit

Permalink
enable logging to remote endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
stCarolas committed Mar 9, 2024
1 parent c873b21 commit a97f3c7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 6 additions & 6 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PORT=3001
REACT_APP_ENDPOINT=http://localhost:3001
REACT_APP_PINO_LOG_LEVEL=debug
REACT_APP_API_ENDPOINT=http://localhost:8080
REACT_APP_CONFIG_API_ENDPOINT=http://localhost:8081
REACT_APP_WIDGET_API_ENDPOINT=http://localhost:8082
REACT_APP_API_ENDPOINT=http://localhost
REACT_APP_CONFIG_API_ENDPOINT=http://localhost
REACT_APP_WIDGET_API_ENDPOINT=http://localhost
REACT_APP_FILE_API_ENDPOINT=http://localhost:8083
REACT_APP_RECIPIENT_API_ENDPOINT=http://localhost:8084
REACT_APP_MEDIA_API_ENDPOINT=http://localhost:8085
REACT_APP_RECIPIENT_API_ENDPOINT=http://localhost
REACT_APP_MEDIA_API_ENDPOINT=http://localhost
REACT_APP_LOG_API_ENDPOINT=http://localhost:8000
REACT_APP_WS_ENDPOINT=ws://127.0.0.1:15674/ws
REACT_APP_WS_ENDPOINT=ws://10.43.95.70:15674/ws
REACT_APP_CDN_ENDPOINT=http://localhost:9000/public
1 change: 1 addition & 0 deletions src/components/MediaWidget/PlaylistController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export class PlaylistController {

finishSong() {
const song = this.current.song();
log.debug(`finishing song: ${JSON.stringify(song)}`);
if (song?.id) {
this.current.markListened(song?.id);
}
Expand Down
10 changes: 4 additions & 6 deletions src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import pino from "pino";

// todo локально работает, надо сделать чтобы по флагу/команде включалось в проде
const send = async function (level, logEvent) {
const url = `${process.env.REACT_APP_LOG_API_ENDPOINT}/api/v1/logstream/widgets`;
const url = `${process.env.REACT_APP_LOG_API_ENDPOINT}/logs/${localStorage.getItem("login")}`;

try {
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Basic YWRtaW46YWRtaW4K",
"Content-Type": "application/json",
"X-P-Meta-user-id": localStorage.getItem("login"),
},
body: JSON.stringify([logEvent]),
});
Expand All @@ -23,9 +21,9 @@ const log = pino({
browser: {
serialize: true,
asObject: true,
// transmit: {
// send,
// },
transmit: {
send,
},
},
});
log.level = process.env.REACT_APP_PINO_LOG_LEVEL || "debug";
Expand Down
3 changes: 3 additions & 0 deletions src/logic/playlist/Playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class Playlist {
this._songs.map((song) => {
if (song.id === id) {
if (song.originId) {
log.debug(`mark as listened: ${song.title}`);
markListened(song.originId);
}
}
Expand All @@ -119,11 +120,13 @@ class Playlist {
}

nextSong() {
log.debug(`setting next song`);
if (this._index != null) {
this._index = this._index + 1;
if (this._index >= this._songs.length) {
this._index = null;
}
log.debug(`next song index: ${this._index}`);
}
this.triggerListeners();
}
Expand Down

0 comments on commit a97f3c7

Please sign in to comment.