Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/FileUtils.java @ 654:12a4f60ea972
1) Console push tool. 2) Pass class to blame into FileUtils
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 03 Jul 2013 15:11:40 +0200 |
parents | ffce73efa2c2 |
children | 24f4efedc9d5 |
comparison
equal
deleted
inserted
replaced
653:629a7370554c | 654:12a4f60ea972 |
---|---|
35 * @author TMate Software Ltd. | 35 * @author TMate Software Ltd. |
36 */ | 36 */ |
37 public final class FileUtils { | 37 public final class FileUtils { |
38 | 38 |
39 private final LogFacility log; | 39 private final LogFacility log; |
40 private final Class<?> troublemaker; | |
40 | 41 |
41 public static void copyFile(File from, File to) throws HgIOException { | 42 public static void copyFile(File from, File to) throws HgIOException { |
42 new FileUtils(new StreamLogFacility(Debug, true, System.err)).copy(from, to); | 43 new FileUtils(new StreamLogFacility(Debug, true, System.err), FileUtils.class).copy(from, to); |
43 } | 44 } |
44 | 45 |
45 public FileUtils(LogFacility logFacility) { | 46 public FileUtils(LogFacility logFacility, Object troubleSource) { |
46 log = logFacility; | 47 log = logFacility; |
48 if (troubleSource == null) { | |
49 troublemaker = null; | |
50 } else { | |
51 troublemaker = troubleSource instanceof Class ? (Class<?>) troubleSource : troubleSource.getClass(); | |
52 } | |
47 } | 53 } |
48 | 54 |
49 public void copy(File from, File to) throws HgIOException { | 55 public void copy(File from, File to) throws HgIOException { |
50 FileInputStream fis = null; | 56 FileInputStream fis = null; |
51 FileOutputStream fos = null; | 57 FileOutputStream fos = null; |
102 if (f == null) { | 108 if (f == null) { |
103 msg = "Exception while closing stream quietly"; | 109 msg = "Exception while closing stream quietly"; |
104 } else { | 110 } else { |
105 msg = String.format("Failed to close %s", f); | 111 msg = String.format("Failed to close %s", f); |
106 } | 112 } |
107 log.dump(getClass(), Severity.Warn, ex, msg); | 113 log.dump(troublemaker == null ? getClass() : troublemaker, Severity.Warn, ex, msg); |
108 } | 114 } |
109 } | 115 } |
110 } | 116 } |
111 } | 117 } |