Esempio n. 1
0
        public async Task LogRequest <TReq>(Guid correlationId, string serviceName, TReq request) where TReq : new()
        {
            var msg = await _logObjectSerializer.Serialize(request);

            await _bus.PubSub.PublishAsync(new ServiceLogMessage
            {
                CorrelationId = correlationId,
                Event         = "Request",
                Service       = serviceName,
                Message       = msg
            });
        }
Esempio n. 2
0
        public LogEntry CreateLogEntry(Guid softwareId)
        {
            if (Message != null && Object != null)
            {
                return(new LogEntry
                {
                    SoftwareId = softwareId,
                    Level = Level,
                    Object = _serializer.Serialize(new MessageAndObjectLog(Message, Object)),
                    ObjectType = typeof(MessageAndObjectLog).FullName
                });
            }
            if (Message != null)
            {
                return(new LogEntry
                {
                    SoftwareId = softwareId,
                    Level = Level,
                    Object = Message,
                    ObjectType = typeof(string).FullName
                });
            }
            if (Object != null)
            {
                return(new LogEntry
                {
                    SoftwareId = softwareId,
                    Level = Level,
                    Object = Object == null ? null : _serializer.Serialize(Object),
                    ObjectType = Object?.GetType().FullName
                });
            }

            return(new LogEntry
            {
                SoftwareId = softwareId,
                Level = Level,
                Object = "Empty Log Entry",
                ObjectType = typeof(string).FullName
            });
        }
Esempio n. 3
0
        public async Task LogRequest <TReq>(Guid correlationId, string serviceName, TReq request) where TReq : new()
        {
            var data = await _logObjectSerializer.Serialize(request);

            _logger.LogInformation("Request: {serviceName}:{correlationId} {data}", serviceName, correlationId, data);
        }
Esempio n. 4
0
 public void Log(object o)
 {
     Logger.Info(_serializer.Serialize(o));
 }