Skip to content

Commit 6c2a9a5

Browse files
pallakartheekreddyclaudemaheshkumargangula
authored
refactor: replace println/System.out.println with TelemetryManager lo… (#1191)
* refactor: replace println/System.out.println with TelemetryManager logging Replace all raw println and System.out.println calls in business logic with structured TelemetryManager calls (debug/error/warn) so that log output is captured by the platform's logging pipeline and not silently dropped in production. Files changed: - ContentActor.scala: warn for missing default licence - ChannelManager.scala: error for category fetch failure (added import) - NodeValidator.scala: debug for singular identifier lookup (added import) - DataSubGraph.scala: debug for subgraph traversal diagnostics (added import) - StorageService.scala: error for getUri exception (added import) - CollectionTOCUtil.scala: error for validateDIALCodes exception - ObjectCategoryDefinitionActor.scala: debug for fallback _all lookup (added import) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Apply suggestion from @maheshkumargangula Co-authored-by: Mahesh Kumar Gangula <6985261+maheshkumargangula@users.noreply.github.com> * Apply suggestion from @maheshkumargangula Co-authored-by: Mahesh Kumar Gangula <6985261+maheshkumargangula@users.noreply.github.com> --------- Co-authored-by: Claude <claude@anthropic.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Mahesh Kumar Gangula <6985261+maheshkumargangula@users.noreply.github.com>
1 parent 464cb13 commit 6c2a9a5

File tree

7 files changed

+14
-11
lines changed

7 files changed

+14
-11
lines changed

content-api/collection-csv-actors/src/main/scala/org.sunbird/collectioncsv/util/CollectionTOCUtil.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ object CollectionTOCUtil {
5555
returnDIALCodes.asScala.toList.map(rec => rec.asScala.toMap[String,AnyRef]).map(_.getOrElse(CollectionTOCConstants.IDENTIFIER, "")).asInstanceOf[List[String]]
5656
}
5757
catch {
58-
case e:Exception => println("CollectionTOCUtil: validateDIALCodes --> exception: " + e.getMessage)
58+
case e:Exception => TelemetryManager.error("CollectionTOCUtil: validateDIALCodes --> exception: " + e.getMessage, e)
5959
List.empty
6060
}
6161
}

content-api/content-actors/src/main/scala/org/sunbird/channel/managers/ChannelManager.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.mashape.unirest.http.Unirest
1212
import org.apache.commons.collections4.CollectionUtils
1313
import org.apache.commons.lang3.StringUtils
1414
import org.sunbird.common.JsonUtils
15+
import org.sunbird.telemetry.logger.TelemetryManager
1516

1617
import scala.jdk.CollectionConverters._
1718
import scala.collection.mutable.ListBuffer
@@ -104,7 +105,7 @@ object ChannelManager {
104105
} catch {
105106
case e: Exception =>
106107
// Log error and continue without populating categories
107-
System.out.println("Error fetching primary/additional categories: " + e.getMessage)
108+
TelemetryManager.error("Error fetching primary/additional categories: " + e.getMessage, e)
108109
}
109110
}
110111

content-api/content-actors/src/main/scala/org/sunbird/content/actors/ContentActor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class ContentActor @Inject() (implicit oec: OntologyEngineContext, ss: StorageSe
272272
TelemetryManager.error("Error setting license to Redis: " + e.getMessage, e)
273273
}
274274
} else {
275-
println("Default License is not available for channel: " + channelId)
275+
TelemetryManager.warn("Default License is not available for channel: " + channelId)
276276
}
277277
}).recover {
278278
case e: Exception =>

ontology-engine/graph-core_2.13/src/main/scala/org/sunbird/graph/validator/NodeValidator.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.sunbird.graph.common.enums.SystemProperties
99
import org.sunbird.graph.dac.model.{Filter, MetadataCriterion, Node, SearchConditions, SearchCriteria}
1010
import org.sunbird.graph.exception.GraphErrorCodes
1111
import org.sunbird.graph.service.operation.SearchAsyncOperations
12+
import org.sunbird.telemetry.logger.TelemetryManager
1213
import scala.jdk.CollectionConverters._
1314

1415
import scala.collection.convert.ImplicitConversions._
@@ -34,7 +35,7 @@ object NodeValidator {
3435

3536
private def getDataNodes(graphId: String, identifiers: util.List[String])(implicit ec: ExecutionContext, oec: OntologyEngineContext) = {
3637
if (identifiers.size() == 1) {
37-
System.out.println("NodeValidator: Singular lookup for identifier: " + identifiers.get(0))
38+
TelemetryManager.debug("NodeValidator: Singular lookup for identifier: " + identifiers.get(0))
3839
oec.graphService.getNodeByUniqueId(graphId, identifiers.get(0), false, new org.sunbird.common.dto.Request())
3940
.map(node => util.Arrays.asList(node))
4041
.recover {

ontology-engine/graph-engine_2.13/src/main/scala/org/sunbird/graph/path/DataSubGraph.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import org.sunbird.graph.dac.model.{Node, Relation, SubGraph}
99
import org.sunbird.graph.nodes.DataNode
1010
import org.sunbird.graph.schema.{DefinitionFactory, DefinitionNode, ObjectCategoryDefinition}
1111
import org.sunbird.graph.utils.NodeUtil
12+
import org.sunbird.telemetry.logger.TelemetryManager
1213
import scala.jdk.CollectionConverters._
1314
import org.sunbird.graph.utils.NodeUtil.{convertJsonProperties, handleKeyNames}
1415

@@ -37,7 +38,6 @@ object DataSubGraph {
3738
val dataMap = new util.HashMap[String, AnyRef]
3839
val relMap = new util.HashMap[String, AnyRef]
3940
readSubGraphData(request, dataMap, relMap).map(sub => {
40-
println("subGraphData out " + sub)
4141
sub
4242
})
4343
}
@@ -60,7 +60,7 @@ object DataSubGraph {
6060
})
6161
finalDataMap.asScala.map(entry => {
6262
val mapData = entry._2.asInstanceOf[java.util.Map[String, AnyRef]].asScala
63-
println("mapData " + mapData.toString())
63+
TelemetryManager.debug("mapData " + mapData.toString())
6464
val outRelations: util.List[Relation] = mapData.getOrElse("outRelations", new util.ArrayList[Relation]).asInstanceOf[util.List[Relation]]
6565
for (rel <- outRelations.asScala) {
6666
val subReq = new Request()
@@ -71,7 +71,7 @@ object DataSubGraph {
7171
subReq.getContext.put("objectType", rel.getEndNodeObjectType)
7272
subReq.getContext.put("isRoot", "true")
7373
subReq.put("identifier", rel.getEndNodeId)
74-
println("readSubGraphData "+ readSubGraphData(subReq, dataMap, relMap))
74+
TelemetryManager.debug("readSubGraphData " + subReq.get("identifier"))
7575
}
7676
})
7777
Future{finalDataMap}
@@ -107,7 +107,6 @@ object DataSubGraph {
107107
finalMetadata.keySet.retainAll(fields)
108108
finalMetadata.put("identifier", node.getIdentifier)
109109
}
110-
println("definitionMap "+ definitionMap)
111110
val relMap: util.Map[String, util.List[util.Map[String, AnyRef]]] = geOutRelationMap(node, updatedMetadataMap, definitionMap)
112111
finalMetadata.putAll(relMap)
113112
finalMetadata

platform-modules/mimetype-manager/src/main/scala/org/sunbird/cloudstore/StorageService.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.sunbird.cloud.storage.BaseStorageService
66
import org.sunbird.cloud.storage.factory.{StorageConfig, StorageServiceFactory}
77
import org.sunbird.common.{Platform, Slug}
88
import org.sunbird.common.exception.ServerException
9+
import org.sunbird.telemetry.logger.TelemetryManager
910

1011
import java.io.File
1112
import scala.concurrent.{ExecutionContext, Future}
@@ -97,7 +98,7 @@ class StorageService {
9798
getService.getUri(getContainerName, key, Option.apply(false))
9899
} catch {
99100
case e:Exception =>
100-
println("StorageService --> getUri --> Exception: " + e.getMessage)
101+
TelemetryManager.error("StorageService --> getUri --> Exception: " + e.getMessage, e)
101102
""
102103
}
103104
}

taxonomy-api/taxonomy-actors/src/main/scala/org/sunbird/actors/ObjectCategoryDefinitionActor.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import javax.inject.Inject
77
import org.apache.commons.lang3.StringUtils
88
import org.sunbird.actor.core.BaseActor
99
import org.sunbird.common.{JsonUtils, Slug}
10+
import org.sunbird.telemetry.logger.TelemetryManager
1011
import org.sunbird.common.dto.{Request, Response, ResponseHandler}
1112
import org.sunbird.common.exception.{ClientException, ResourceNotFoundException}
1213
import org.sunbird.graph.OntologyEngineContext
@@ -78,7 +79,7 @@ class ObjectCategoryDefinitionActor @Inject()(implicit oec: OntologyEngineContex
7879
DataNode.read(request) recoverWith {
7980
case e: ResourceNotFoundException => {
8081
val id = request.get(Constants.IDENTIFIER).asInstanceOf[String]
81-
println("ObjectCategoryDefinitionActor ::: read ::: node not found with id :" + id + " | Fetching node with _all")
82+
TelemetryManager.debug("ObjectCategoryDefinitionActor ::: read ::: node not found with id :" + id + " | Fetching node with _all")
8283
if (StringUtils.equalsAnyIgnoreCase("POST", requestMethod) && !StringUtils.endsWithIgnoreCase(id, "_all")) {
8384
request.put(Constants.IDENTIFIER, id.replace(id.substring(id.lastIndexOf("_") + 1), "all"))
8485
DataNode.read(request)
@@ -87,7 +88,7 @@ class ObjectCategoryDefinitionActor @Inject()(implicit oec: OntologyEngineContex
8788
}
8889
case e: CompletionException if e.getCause.isInstanceOf[ResourceNotFoundException] => {
8990
val id = request.get(Constants.IDENTIFIER).asInstanceOf[String]
90-
println("ObjectCategoryDefinitionActor ::: read ::: node not found with id :" + id + " | Fetching node with _all")
91+
TelemetryManager.debug("ObjectCategoryDefinitionActor ::: read ::: node not found with id :" + id + " | Fetching node with _all")
9192
if (StringUtils.equalsAnyIgnoreCase("POST", requestMethod) && !StringUtils.endsWithIgnoreCase(id, "_all")) {
9293
request.put(Constants.IDENTIFIER, id.replace(id.substring(id.lastIndexOf("_") + 1), "all"))
9394
DataNode.read(request)

0 commit comments

Comments
 (0)