-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #448 from jluhrs/log_subscription
Implemented logs subscription in GraphQl.
- Loading branch information
Showing
12 changed files
with
260 additions
and
110 deletions.
There are no files selected for viewing
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
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
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
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
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
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
49 changes: 0 additions & 49 deletions
49
modules/web/server/src/main/scala/navigate/web/server/logging/AppenderForClients.scala
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
modules/web/server/src/main/scala/navigate/web/server/logging/LogMessageBuilder.scala
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
modules/web/server/src/main/scala/navigate/web/server/logging/SubscriptionAppender.scala
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,31 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package navigate.web.server.logging | ||
|
||
import cats.effect.std.Dispatcher | ||
import ch.qos.logback.classic.Level | ||
import ch.qos.logback.classic.spi.ILoggingEvent | ||
import ch.qos.logback.core.UnsynchronizedAppenderBase | ||
import fs2.concurrent.Topic | ||
|
||
class SubscriptionAppender[F[_]](logTopic: Topic[F, ILoggingEvent])(using dispatcher: Dispatcher[F]) | ||
extends UnsynchronizedAppenderBase[ILoggingEvent] { | ||
// Remove some loggers. This is a weak form of protection where he don't send some | ||
// loggers to the client, e.g. security related logs | ||
private val blackListedLoggers = List(""".*\.security\..*""".r) | ||
|
||
override def append(event: ILoggingEvent): Unit = | ||
// Send a message to the clients if level is INFO or higher | ||
// We are outside the normal execution loop, thus we need to call unsafePerformSync directly | ||
if ( | ||
event.getLevel.isGreaterOrEqual(Level.INFO) && !blackListedLoggers.exists( | ||
_.findFirstIn(event.getLoggerName).isDefined | ||
) | ||
) | ||
dispatcher.unsafeRunAndForget( | ||
logTopic.publish1(event) | ||
) | ||
else () | ||
|
||
} |
14 changes: 0 additions & 14 deletions
14
modules/web/server/src/main/scala/navigate/web/server/logging/package.scala
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.