Skip to content

Commit

Permalink
Fixes openwallet-foundation#3202: new suppress banner and replace pri…
Browse files Browse the repository at this point in the history
…nt by logging statements

Signed-off-by: Ricky Ng-Adam <[email protected]>
  • Loading branch information
rngadam committed Aug 28, 2024
1 parent 90895bb commit 2dd65ce
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion aries_cloudagent/anoncreds/default/did_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def supported_identifiers_regex(self) -> Pattern:

async def setup(self, context: InjectionContext):
"""Setup."""
print("Successfully registered DIDIndyRegistry")
LOGGER.info("Successfully registered DIDIndyRegistry")

async def get_schema(self, profile: Profile, schema_id: str) -> GetSchemaResult:
"""Get a schema from the registry."""
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/anoncreds/default/did_web/registry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""DID Web Registry."""

import logging
import re
from typing import Optional, Pattern, Sequence

Expand All @@ -17,6 +18,7 @@
)
from ...models.anoncreds_schema import AnonCredsSchema, GetSchemaResult, SchemaResult

LOGGER = logging.getLogger(__name__)

class DIDWebRegistry(BaseAnonCredsResolver, BaseAnonCredsRegistrar):
"""DIDWebRegistry."""
Expand All @@ -40,7 +42,7 @@ def supported_identifiers_regex(self) -> Pattern:

async def setup(self, context: InjectionContext):
"""Setup."""
print("Successfully registered DIDWebRegistry")
LOGGER.info("Successfully registered DIDWebRegistry")

async def get_schema(self, profile, schema_id: str) -> GetSchemaResult:
"""Get a schema from the registry."""
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def supported_identifiers_regex(self) -> Pattern:

async def setup(self, context: InjectionContext):
"""Setup."""
print("Successfully registered LegacyIndyRegistry")
LOGGER.info("Successfully registered LegacyIndyRegistry")

@staticmethod
def make_schema_id(schema: AnonCredsSchema) -> str:
Expand Down
10 changes: 10 additions & 0 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,15 @@ def add_arguments(self, parser: ArgumentParser):
"('debug', 'info', 'warning', 'error', 'critical')"
),
)
parser.add_argument(
"--no-banner",
action="store_true",
env_var="ACAPY_NO_BANNER",
default=False,
help=(
"Suppress banner in logs"
),
)

def get_settings(self, args: Namespace) -> dict:
"""Extract logging settings."""
Expand All @@ -1038,6 +1047,7 @@ def get_settings(self, args: Namespace) -> dict:
settings["log.file"] = args.log_file
if args.log_level:
settings["log.level"] = args.log_level
settings["log.banner"] = not args.no_banner
return settings


Expand Down
35 changes: 18 additions & 17 deletions aries_cloudagent/core/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,24 +318,25 @@ async def start(self) -> None:
# Get agent label
default_label = context.settings.get("default_label")

if context.settings.get("transport.disabled"):
LoggingConfigurator.print_banner(
default_label,
None,
None,
self.setup_public_did and self.setup_public_did.did,
self.admin_server,
)
else:
LoggingConfigurator.print_banner(
default_label,
self.inbound_transport_manager.registered_transports,
self.outbound_transport_manager.registered_transports,
self.setup_public_did and self.setup_public_did.did,
self.admin_server,
)
if context.settings.get('log.banner'):
if context.settings.get("transport.disabled"):
LoggingConfigurator.print_banner(
default_label,
None,
None,
self.setup_public_did and self.setup_public_did.did,
self.admin_server,
)
else:
LoggingConfigurator.print_banner(
default_label,
self.inbound_transport_manager.registered_transports,
self.outbound_transport_manager.registered_transports,
self.setup_public_did and self.setup_public_did.did,
self.admin_server,
)

LoggingConfigurator.print_notices(context.settings)
LoggingConfigurator.print_notices(context.settings)

# record ACA-Py version in Wallet, if needed
from_version_storage = None
Expand Down

0 comments on commit 2dd65ce

Please sign in to comment.