Project

General

Profile

« Previous | Next » 

Revision 26991

modified the log date format

View differences:

modules/dnet-modular-logging/trunk/src/main/java/eu/dnetlib/common/logging/LogMessage.java
15 15

  
16 16
	public static final String LOG_LEVEL_FIELD = "log:level";
17 17
	public static final String LOG_DATE_FIELD = "log:date";
18
	public static final String LOG_PRETTY_PRINT_DATE = "log:date:pretty";
19 18

  
20 19
	public LogMessage(final DnetLoggerDao dao, final String logname, final DnetLogLevel level) {
21 20
		this.dao = dao;
22 21
		this.details = Maps.newHashMap();
23 22
		this.details.put(LOG_LEVEL_FIELD, level.toString());
24
		this.details.put(LOG_DATE_FIELD, new Date());
23
		this.details.put(LOG_DATE_FIELD, (new Date()).getTime());
25 24
		this.logname = logname;
26 25
	}
27 26

  
modules/dnet-mongo-logging/trunk/src/main/java/eu/dnetlib/common/logging/dao/DnetLoggerMongoDao.java
16 16
import com.mongodb.DBObject;
17 17

  
18 18
import eu.dnetlib.common.logging.LogMessage;
19
import eu.dnetlib.miscutils.datetime.DateUtils;
20 19

  
21 20
public class DnetLoggerMongoDao implements DnetLoggerDao {
22 21

  
......
112 111
	private Map<String, String> dbObject2Map(final DBObject obj) {
113 112
		final Map<String, String> res = Maps.newHashMap();
114 113
		for (String k : obj.keySet()) {
115
			if (k.equals(LogMessage.LOG_DATE_FIELD) && (obj.get(k) instanceof Date)) {
116
				res.put(LogMessage.LOG_DATE_FIELD, DateUtils.calculate_ISO8601(((Date) obj.get(k)).getTime()));
117
				res.put(LogMessage.LOG_PRETTY_PRINT_DATE, "" + obj.get(k));
118
			} else {
119
				res.put(k, "" + obj.get(k));
120
			}
114
			res.put(k, "" + obj.get(k));
121 115
		}
122 116
		return res;
123 117
	}

Also available in: Unified diff